by brokencode · 4y ago · 0 comments
Memorizing the common problems gives you a big leg up on being able to successfully pass an interview.
What you do need to memorize are a small group of algorithmic designs and have a good sense of when to apply each one. The main ones include divide and conquer, greedy, graph, and what seems to be the hardest of them all, dynamic programming algorithms.
It's disappointing that so few developers know these or are comfortable with these designs since employing them provides significant speedups to what would otherwise involve deeply nested loops or other naive brute force solutions. Becoming familiar with the broad set of algorithm designs is something most competent developers should invest some time in, and it's not like it requires years and years to become good at it but the benefits are enormous.
There are much worse ones on leetcode, and people expecting you to get the optimal solution are absurd. I fully expect to fail those unless I'm lucky. I don't study leetcode problems, because my interview approach is to first and foremost, implement a naive (aka slow) but correct solution in the time allotted, then engage in a conversation about ideas for improving it (not a rewrite). This has worked for me for decades, and it's also what I expect of people I'm interviewing.
This type of approach allows the interviewee to demonstrate that 1) they can write basic code, 2) they can solve a problem, 3) they can critique their own code and discuss perf implications, 4) they can think of ways to improve it even if they don't necessarily have time for a rewrite, and it allows the interviewer to demonstrate that they aren't a dick who's just playing "I'm smarter than you because I'm in the advantaged position."
I agree it’s probably mostly memorized as an answer today, but I don’t think it’s fundamentally a bad question.