Help - Encoding June - Delta wants treats - ECJN205

question link -
Here is my code link-
this code gives runtime error,then how to apply BFS in this ques. having large constraint within 1sec time limit…pls. help & give idea of how to solve such type problems.

You should use adjacency list to store the graph instead of the adjacency matrix. You can check my submission to see the implementation.
I have simply done a bfs and maintained the distance of each node from the source. If I encounter any node which does not have a treat I don’t move forward from that node. If I reach the destination I stop the bfs and mark the ans as distance of the destination node.

but in C language i facing issues.

If you want to implement it in C then make use of pointers to store the graph in the form of adjacency list.

Ok,thank you,for your help. :+1:

last of all without using pointer solved it in C.