When you solve a problem, do you feel the need to "pass" on Leetcode? Don't feel that way. It's completely unnecessary.
Running code on Leetcode is a giant waste of time. Stay away if you can.
I was talking to a friend of mine, and he was very proud of the fact that he solved 150 problems on Leetcode. He loved his profile. It was proof of his accomplishment.
"See, I've solved 150 problems", he said, showing off his profile.
I said, "How long did it take you?"
Him: "1 year."
Me: "One year? Why would it take you that long. 150 problems shouldn't take more than 2 months."
Him: "Well, I actually DID them, like I passed all the test cases and stuff. It takes time to do that."
Me: "For each question, how long did it take for test cases to pass?"
Him: "Generally around half an hour to debug the code and pass all test cases. Sometimes it took an hour."
Me: "Wait what?! How is that a good thing?"
Him: "I don't know, it makes me feel good to pass everything. Isn't that what Google is looking for?"
Me: "No, they never ask you to pass hundreds of test cases. How did it help you?"
Him: "Not sure, it just made me feel good, I guess. That's all."
This is a giant waste of time. You get this feeling of "incompleteness" if your code doesn't pass on Leetcode.
I still don't understand why people fall for this. In an interview, you will verify code yourself. You don't have a magic box that tells you - "pass" or "fail".
Instead, you will walk through your code and try it out with 5-8 test cases. That's all. It takes 5 minutes at most.
When you verify code on Leetcode, you're not building this skill of verifying code yourself. You're falling for convenience.
I call these Leetcode Crutches. If you start walking with a crutch, you won't build muscles in your leg. That's what's happening here.
And that's not even the biggest issue with this. The biggest issue is - you don't need to verify code with 100+ test cases! Time spent debugging on Leetcode is time down the drain.
Guess who benefits from this - Leetcode of course. The more people spend time on the site, the more money they make. It completely makes sense for them to encourage you to debug each and every part of your code. Keep you addicted to this feel-good notion of passing every test case.
Ok, so what should you do?
In reality, if you walk through your code and test it with a few core test cases, interviewers are more than happy. Companies are not stupid. They know you can't write perfect code in 30 minutes and pass every edge case in existence.
Avoid Leetcode Crutches. Don't stress about running code on Leetcode.
Balance Check [1]
I'm not saying - "don't run code at all". Generally, for your first 20 problems or so, I recommend running code on an IDE. Or on Leetcode if you really want to. This way, you know you're using the right syntax.
Beyond that, I personally don't run code at all. Instead, I practice verifying the code myself. I find that this saves a lot of time.
But there are many other ways to do this - do what suits you best.
Exception
Some companies will give you take-home tests (like HackerRank tests), where your code needs to pass all test cases. For such scenarios, you can practice passing all test cases.
However, this is an exception rather than the norm. Additionally, once you're good at verifying code yourself, you can always practice passing these cases in a Leetcode-like environment.