Back to problems

Find the Safest Path in a Grid

Algorithm · Intuit · Hard

You receive an n x n matrix of binary integers named grid, with the following meanings: A value of 1 at grid[i][j] means that location contains a thief. A value of 0 at grid[i][j] means that location is vacant. Starting from the upper-left position (0, 0), you must travel to the lower-right position (n-1, n-1). Each step may go one cell north, south, west, or east, provided that destination lies inside the matrix. For any route, its safeness factor is the smallest Manhattan…

Checking your access…