Minimum Cost to Move Within a Grid (Akuna Shang Hai )
Problem Overview
- Compute the minimum cost to move a player on a grid from (initR, initC) to (finalR, finalC), moving only up/down/left/right.
- Moving between rows costs costRows[i] and between columns costs costCols[j]; lasers restrict transitions.
- Input: rows, cols, start/goal, costRows[rows-1], costCols[cols-1]; Output: an int minimum cost.
- Constraints: rows, cols up to 1e5; costs are non-negative.
- Asked in Akuna Shanghai interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
