I am doing a simple BFS for this question. I maintain a hashed list of the digit postions in a vector.
And then i push into the queue the indexes c+1,c-1 and the hashed ones.(Normal BFS).
Now this fact surprised me that when i did not use clear() function, i was getting TLE. Got AC after clearing the lists for visited digits.Can anyone explain why??
the submission id are-6489474(TLE)
PS-Spent a lot of time on this seemingly simple question.Thanks in advance.