Problem Description: You are given a N x M grid maze where N is the number of rows and M is the number of columns with S as the starting point, and D as the destination point. Find the shortest distance from the starting point to the destination point if there are any paths. Highlight one of the optimal paths. Note: You may not use points with a 0 value.

Solution: Since this is a traversal problem, I'm using breath-first-search to explore all the paths and keeping track of the visited points and their distance. And backtrack to find the most optimal/shortest path.

Application: E.g. Solve problems that can be represented in a grid system, Find shortest path in a maze, Find minimum cost between two vertex, Detect a cycle in an undirected graph etc.

s = start, d = destination, * = there is path, 0 = path is blocked

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0