Finds a shortest path from the start to the finish

I am trying to solve the following problem, but I am not exactly sure what approch to follow. I would really appriciate if you could share any suggestions, refference materials that would help me to solve it.

Problem: Lets say you are given matrix like this.

.....@...S
....@.....
@.....@..@
...@....@.
.F......@.
.@........
.......@..
.@.@..@..@
@.........
.@@.....@.

S: Start
F: Finish
@: Obstacles

Each turn you have to choose one of the four cardinal directions to move. You have to keep moving in the choosen direction until you hit the wall surrounding the area, or one of the Obstacles. implement an algorithm which finds a shortest path from the start to the finish.

The final output should look like this.

Move left to (7,1)
Move down to (7,2)
Move left to (6,2)
Move down to (6,10)
Move right to (8,10)
Move up to (8,8)
Move right to (9,8)
Move up to (9,6)
Move left to (3,6)
Move up to (3,1)
Move left to (1,1)
Move down to (1,2)
Move right to (4,2)
Move down to (4,3)
Move left to (2,3)
Move down to (2,5)

Also if there are any similar questions in Leetcode, please share as well.

Comments (4)