What is the function of vector.clear() in DIGJUMP?

I was recently solving the question DIGJUMP ( DIGJUMP Problem - CodeChef ) a few days ago and I had initially submitted the solution given in the link CodeChef: Practical coding for everyone . The result was a TLE, I was unable to understand why this problem was occurring but sooner or later I submitted the solution CodeChef: Practical coding for everyone . 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.

if you would not clear the vector then vector size increases with every test case …the next test case also accesses the elements in the vector that you used in the last test case…so you have to clear the vector

@raja44ever, I guess you haven’t read the question properly, there will be only one graph in the question as there is only one test case/ one string.

Even if there were multiple test cases, I would have gotten a WA and not a TLE.
So I request you to please read the question first.