Interview Guides

Given a 2D grid maze of non-negative integers, find the minimum total cost to move from the top-left cell (0, 0) to the bottom-right cell (m-1, n-1). You may move up, down, left, or right. Entering a cell adds that cell’s cost to the path total, including the starting and ending cells. Return -1 if the destination cannot be reached.
1 <= m, n <= 200maze[i][j] is either -1 (blocked) or an integer in [0, 10^6]-1 if (0, 0) or (m-1, n-1) is blocked