sir i have tried dijktras approach but 1 answer is showing wrong upon submission
Https://ide.codingblocks.com/s/207191 BFS-Shortest path
@Adarshrajpandey You don’t need to use dijkstra for this question. This can be solved using bfs traversal. And the time for dijkstra will be nlogn whereas for bfs it will be 0(n)
i have done this using bfs but it is not passing showing tle in one and wrong ans in the other
please check this code
@Adarshrajpandey This is not a proper way to check visited array. unordered_map<int,bool>visited;
Initially it is empty so none of the nodes are assigned any value. Use an array for visited check.
please check sir,sorry for the inconvenience caused sir
but please tell the mistake as i m not able to find out
I have tired the as u hae told but one answer is ginving wrong!
@Adarshrajpandeysince you are very close to the answer I would leave it as a homework for you to learn and understand how the BFS works and get your code accepted yourself.
thanks sir for working so hard on me!!