2 ms·
During the last 10 years i always go for a solution, just a coded solution (and if you do it quickly, or even while doing it, you can frequently improve upon it
by trhway 11y ago
During the last 10 years i always go for a solution, just a coded solution (and if you do it quickly, or even while doing it, you can frequently improve upon it significantly). Doesn't work for Google/FB - they probably want the elegant super-performant solution that i usually come up with in the next few minutes after the interview is finished :) - yet it works just fine with the rest of the companies.
Hint: almost always start with putting the input into a tree, and if tree is completely out of question - into hashmap :)