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: