Plz anyone Explain how to do this problem https://www.codechef.com/ISCC2017/problems/AHHOUSE/

please explain approach for this question.i think backtracking is the main key here

Try using any one of the shortest path algorithms in Graph Theory like Dijkstraâ€™s or Floyd Warshall. Think of the 2D Matrix as a graph with each cell as a vertex and each of its adjacent neighbors (up, down, left and right) as the neighboring vertices of that vertex.

1 Like