5 ms·
What LeetCode does really, really well is have a ton of test cases and chances are you will fail one of them and will have to try again. So they may explain a p
by ping_pong 5y ago
What LeetCode does really, really well is have a ton of test cases and chances are you will fail one of them and will have to try again. So they may explain a problem to you, but they never tell you the edge cases. For example, question #2 is adding two numbers where each digit of the number is a node of linked list. Simple things like carrying a 1 is easy to forget, but then you need to deal with other edge cases, like what if the lists aren't the same size, etc.
So in terms of testing and finding edge cases to handle, it's really eye opening how deep you may need to go. When I do LeetCode, I try to write my program once and if I fail a test case, I consider my attempt a failure and move onto the next question.
But otherwise, it doesn't make you a better overall programmer. There's no incentive to write maintainable code, and you're incentivized to get the code running as quickly as possible by trying to shave off milliseconds, which usually don't matter as much in real world situations.
- wheelinsupial 5y agoDo you mind elaborating on why all of these test cases doesn’t make you a better overall programmer? I think this would be a great thing to help in coming up with requirements and writing code that doesn’t crash because of edge cases or malformed inputs?
- ping_pong 5y agoAs an engineer you need to know how to be efficient with code. Not every single test case needs to be handled otherwise your code becomes unwieldy and brittle. Sometimes it's okay to handle an exception, write to the log so that you can detect something went wrong, and move on.