Dear Community
I have started CP for quite some time but feel that when I write a few lines of code, I always have to debug it. There always in some way or the other bugs come in my code. Can anyone give practical actionable tips to get out of this problem.
Regards Vedant
Auto comment: topic has been updated by vedantsharma2508 (previous revision, new revision, compare).
you can only one tap the problems far below your level so this is not a problem
everyone debugs their code it is essential that you debug your code and there is no problem with that
try to iterate through your code and read each line and ask yourself what is the input that causes this line to give an incorrect output? or try to find a test case that ruin your idea
also try to put alot of different test cases and test your code with them, and the more you debug your code, the more you will get better at debugging, i am also very bad at debugging but idk this may help you
To reduce the number of bugs, you need to: 1. Write the solution on paper or a white board and make sure it works. 2. Implement the solution in code. Many problems will use mathematical formulas, many different subproblems (dp and combinatorics, greedy and Binary Search ,etc.), and when you realize that you can solve them in your head, you can solve them without writing.