SSwiggy·DSASDE-1Technical Interview
Minimum Cost Path in a Weighted Grid
Problem
Given an m × n grid where each cell has a cost, find the minimum cost to travel from (0,0) to (m-1,n-1). You can move right, left, up, or down.
Example
grid = [[1,3,1],
[1,5,1],
[4,2,1]]
Output: 7 -- path: 1→3→1→1→1
Constraints
- 1 ≤ m, n ≤ 200
- 0 ≤ grid[i][j] ≤ 100
Variants asked at Swiggy
- Diagonal movement allowed
- Some cells are blocked
- You can break
kwalls (blocked cells) — solve with 3D DP
added 6 days ago