Stack-Based Maze Solving
Keep track of the path so far with a stack of array positions.
At the current position, try to extend the path one step by trying to go right, up, left, or down. If none of the neighboring squares is available, backtrack by popping a position off the stack. (If the stack is empty, declare failure.)
When extending the path, push the new position on the stack. Test to see if the new position is the goal. Store 1 in the new position to make it impassable in the future.
If the goal has been reached, output the stack contents as the solution path.