Re:Poll: Is the leetcode grind necessary to land a high payi...
by deckard1 on Thursday January 27, 2022 @03:09PM
(#30105706)
wouldn't be surprised people miss the SQL question. Full stack devs are rather rare nowadays, and it's a bit obscure SQL trivia considering the answer is dependent on which SQL db you're using.
[ Parent
| on HN ]
Re:Poll: Is the leetcode grind necessary to land a high payi...
by throwawaygh on Thursday January 27, 2022 @05:45PM
(#30108075)
Modulo syntax/keywords, I think the following query would work in any modern dialect:
SELECT num FROM
(SELECT num FROM nums ORDER BY num DESC LIMIT 2)
ORDER BY num ASC LIMIT 1;
which is actually nearly identical to the simplest Python solution in terms of the computation that's specified: lambda xs: None if len(xs) == 0 else sorted(xs)[-2:][0]
I think the reason the question is tricky for some is because they either:1) haven't used SQL in a long time and forgot all the syntax, or else
2) don't really "grok" SQL as a model of computation (as opposed to e.g. a data structuring language or something like that).
But both of those seem like good reasons to disqualify someone from a full stack role?