I was recently solving the question DIGJUMP ( http://www.codechef.com/problems/DIGJUMP ) a few days ago and I had initially submitted the solution given in the link http://www.codechef.com/viewsolution/5927298 . The result was a TLE, I was unable to understand why this problem was occurring but sooner or later I submitted the solution http://www.codechef.com/viewsolution/5927433 . The only difference between the two submissions is that in the second link I added a line " graph[number].clear();".
(Note: I am representing my graph as a vector<vector >)
Could someone please explain why this is happening? To the best of my knowledge vector.clear() just frees the memory and has a time complexity of O(1). It is our choice whether we want to free the vector or not. By any chance if memory limits are exceeded I should have a run-time error. But I am unable to understand any correlation with Time limit getting exceeded.