No? You can actually use code to solve problems. Don’t buy into the defeatism surrounding leetcode interviews.
No? You can actually use code to solve problems. Don’t buy into the defeatism surrounding leetcode interviews.
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.
Is the problem with leetcode the content or the process? The process is utterly broken, but any time hiring comes up it feels like most complaints are about the content.
There's the group of people for whom doing these "Algos I" problems in university was relatively painless; not that all problems were "easy" but there's an ease to approaching the problem, and with enough continuous effort the problem is solved. These people also tend to have good retention such that 10 years later, they just need to practice LC for a few weeks and they're back in top form, even if they've been building the easiest CRUD apps for years and not working their brains at all. I've seen this firsthand.
There's another group of people who, for whatever reason, are lacking the facilities to calmly and clearly approach these problems. Doing "Algos I" was a serious grind, and the Brain Toolbox for solving these problems falls apart quickly once the final has been taken. Even if doing relatively complex work at their jobs for years, when it's time to practice LC, it may take months to get anywhere near "top form".
Obviously everyone is on a spectrum between and beyond these two groups, and I fall closer to the latter.
Now add on the fact that there's a person watching you who is going to dictate whether you get a paycheck at all or a 20% boost in income. Or you're like me right now and you've been laid off. Now add on that you need to do it in 20 minutes, each minor mistake potentially becoming a devastating error if you don't catch it quickly.
I envy anyone who can just focus on the problem and remove all surrounding context. Still trying to figure out how I can add stress distractions while timing myself.
This is indeed a good thing to be able to do. I'm pretty good at it, but when I'm in an interview situation, I almost always have at least one moment where I start to panic a little and have to tell myself, "you know what you're doing, just relax and turn the crank." And of course, there's an implied "...but maybe you'll just choke," which I have to put out of my mind.
In other words, a huge part of being able to focus on the problem and remove the surrounding context is a sort of confidence that I can probably do fine, so I can temporarily stop worrying about how I'm looking at any exact moment.
They don’t want thinkers who re-invent the wheel?
They want you to work pretty fast and you only have about 20 minutes to solve one problem at most companies, no way I could work my way through something completely new that quickly.