I'm a beginner in LeetCode, I always find my C++/C solution go to Runtime Error, but it works in my computer. I want to share my debug experience with Runtime Error. I use
printf to output debug information. For example, if the input contains many queries, I will output strings to see the progress my program proceed. Then you will finally find out the bugs.
Mistakes I made:
- doesn't initialize pointer to NULL
- iteration of array exceed the length of the array