Google | Onsite | Frog in a Matrix
3174

Given a 2d array with size n*m, there's some obstacles placed at some points. A frog trying to jump from the beginning point 0,0 to the bottom right point n-1, m-1. Say if a frog can jump maximum k distance a time, what is the minimun steps needed?
Note: the frog can only jump horizontally or vertically, it can't jump diagonally. Obstacles are represented by -1.

eg:
[0,0,-1,0,0,0,
-1,0,0,0,-1,0], maximum step k = 2

answer: 6

Comments (10)