We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Exactly I also did it with Dijkstra, but interesting thing is when cost of all edges are same in graph, then Dijkstra can be reduced to simple BFS with complexity of O(n). So Dijkstra is good but BFS gives better complexity as it is a special case of Dijkstra where cost of all edges are same.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Snakes and Ladders: The Quickest Way Up
You are viewing a single comment's thread. Return to all comments →
Exactly I also did it with Dijkstra, but interesting thing is when cost of all edges are same in graph, then Dijkstra can be reduced to simple BFS with complexity of O(n). So Dijkstra is good but BFS gives better complexity as it is a special case of Dijkstra where cost of all edges are same.