Hello fellow Coders
I just submitted something it got WA after about 7000 test queries were correct. The test input size is huge, so there is no way for me to debug it in a feasible amount of time. I've checked all my code for common errors: long overflow, small issues, whatever. I'm sure this has happened to many people before.... How do you recommend debugging such a case? Is there anything to look for?
Thank you
After you go through your code line by line to check your logic, a common suggestion is to write a brute force correct solution, and a test case generator to try and find a (hopefully small) test case that breaks your incorrect solution.
Good qn. Here's some of my strategy:
The last resort is to write a generator and brute force since that will literally kill your time.
Until recently, I would often have a really hard time debugging when I don't know the test case or when it is really large. I didn't try testing with small test cases because I thought it would be inefficient. But now I've realized that manually trying any test case that I can think of or even just small random test cases is actually more effective than I thought, with me often able to quickly find a test case which causes my solution to fail and use it to find the bug. It's definitely better than
while (!codeWorks()) stareAtCode();
. Of course, it's a good idea to first check for problems specific to large test cases such as overflows and array sizes.