Minimum Dropping Path Sum With Column Distance Constraint
You are given a two-dimensional list of integers matrix. Return the minimum sum you can get by taking a number in each row with the constraint that any row-adjacent numbers can only differ in columns by at most one unit.
Constraints
1 ≤ n ≤ 250wherenis the number of rows inmatrix2 ≤ m ≤ 250wheremis the number of columns inmatrix
https://binarysearch.com/problems/Minimum-Dropping-Path-Sum-With-Column-Distance-Constraint
Examples
Example 1
Input
- matrix =
[[ 3, 0, 3],
[ 1, 4, 3],
[-2, 3,-3]]
Output
- answer =
-1
Explanation
We can take 0 from the first row, 1 from the second row, and -2 from the last row.
Leave a comment