Today I was solving this problem, https://www.codechef.com/problems/INCPR04/, I implemented a solution with O(length of the array) time complexity. But I was getting TLE. Then I looked up at some of the accepted solutions, their logic was same as mine, but they have added these statements:
I have tried doing the same and added these statements to my code and the solution got accepted. But I don’t exactly know what do these statements do. I have searched it on google and opened the first link but I couldn’t a get a lucid idea of what it is exactly doing. Could someone please elaborate what these statements actually do?