r/programming • u/ldxtc • Sep 22 '20
Google engineer breaks down the problems he uses when doing technical interviews. Lots of advice on algorithms and programming.
https://alexgolec.dev/google-interview-questions-deconstructed-the-knights-dialer/
6.4k
Upvotes
2
u/binarycow Sep 23 '20
I don't disagree!
Yeah, if this was an actual interview, and if the problem was given just as it was, with no other requirements... I would be asking clarifying questions. Such as :
are there any guarantees on the number of items?
are there any guarantees on the uniqueness of items?
do we need the second highest number, or the second highest distinct number
how often will this method be called?
what's the typical size of the list?
will there be any issues with deferred execution?
(and yes, I understand the impact of both distinct (I beleive it creates a hashset), and orderbydescending, and if efficiency was important (maybe this is in the critical path), I would replace this with a foreach loop and a variable keeping track of the highest number.