BFS Shortest Path - TLE

I am getting one test case as TLE.

You would need to rewrite your code a bit. To find the shortest path, all you have to do is start from the source and perform a breadth first search and stop when you find your destination Node. The only additional thing you need to do is have an array previous[n] which will store the previous node for every node visited. The previous of source can be null

you can see this: