Skip to interview prep
Apexed

81. Minimum Path Sum in a Grid

MediumDynamic programming

Moving only right or down, return the smallest possible sum of a path from the top-left to the bottom-right of grid.

Example 1

Input: grid = [[1, 3, 1], [1, 5, 1], [4, 2, 1]]
Output: 7
Explanation: 1 → 3 → 1 → 1 → 1

Constraints

  • 1 ≤ rows, columns ≤ 200
  • Values are non-negative

Tab indents · Ctrl/⌘ + Enter runs · Esc then Tab leaves the editor

Run checks these cases; the expected output comes from the reference solution. Submit judges all 3 hidden and sample tests.

Code runs only in your browser in an isolated sandbox. Progress and submissions are saved on this device.

Minimum Path Sum in a Grid — coding interview practice — Apexed