Leetcode is really helpful when preparing for technical interviews. There are over a 1000 curated questions for each company, topic, and difficulty level.
However, you will develop a weakness in if you rely too much on Leetcode.
That is, you will lose the ability to catch your own errors.
You see, Leetcode will run dozens, if not hundreds of test cases against your code at the simple click of the Submit button. This is really useful for users to check against various edge cases, but it also takes away your own ability to catch your own errors.
And this can create a problem at a real interview. At my Google interview, I was writing code on a whiteboard and debugging it manually. You will most likely not get the benefit of having bugs in your code pointed out to you.
But don’t worry. Here are my various tips on how to mitigate this.
- walk through your code after you write it. Take a test case and walk through your code step-by-step, to check that your code is correct
- when your code fails on a test, try to focus on your code and logic instead of the test case and find the bug
- try a different practice medium, like Google's programming competitions
For those of you that didn’t try Google Code Jam, all you need to know is that they don’t show you the error logs when your code is incorrect. No test cases. No error logs. No stack traces. No nothing.
You are simply told whether your solution is incorrect, has a runtime error, or ran out of memory. That’s it.
You are left in the dark. You have no idea what you did wrong. No idea where the error happened. No idea what test case you fail on.
And you know what? It’s one of the best ways to grow your coding skills. If you want strong growth in your coding interview prep, definitely give a past problem a challenge.
That’s all. Hope you learned something. Happy coding! :)