0PricingLogin
Competitive Programming Academy · Lesson

Minimum Path Sum with Obstacles

Carry the best cost across cells.

From Counting to Costing

Now each cell holds a value and you want the cheapest route to the corner. The goal shifts from counting paths to minimizing a cost.

Define the State

Let dp[i][j] be the smallest total cost to reach cell (i, j). Same grid, same moves, but we track sums instead of counts.

All lessons in this course

  1. Path Counting on a Grid
  2. Minimum Path Sum with Obstacles
  3. Longest Common Subsequence
  4. Edit Distance Step by Step
← Back to Competitive Programming Academy