Art Of Reading Code

Hello everyone,

I often find it hard to read other’s code than to write mine own version of code but competitive programming is not just all about writing codes. I have often heard people that you learn a lot when you read other’s code whether its when you are trying to learn something out of other’s code or you are trying to hack a solution in any contest.

Can you throw some light on how one can increase his ability to read totally unfamiliar code easily and understand the algorithm working behind it swiftly.


i use this technique…first i go to the main fxn…then there i try and understand what variables are assigned to the corresponding inputs…if some are unclear then print all those values…for example print the whole array to see what it is exactly storing to see what is getting stored into it if it is being pre-processed…then as and when there is a fxn call…visit that fxn see what it is doing…if u cant understand then print whatever it is doing to get and idea of what changes are being done…create a few cases of your own see what ops you expect and what are you getting…if your expectations match the ops of the code then probably you may have understood the code…in short just trace the code keeping the problem statement in mind…also some good codes have the fxn and variable names as the function they perform or the role they play…target such codes…:slight_smile:

1 Like

@kunal361 thanks.
Any more technique?


Please add more technique.

1 Like

To learn art of reading code, have a look here

1 Like

why do i see the exact same ques and the exact same ans over here???