Skip to content

Practice Minimum Falling Path Sum II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#1289
LeetCode Problem

Minimum Falling Path Sum II

Problem Statement

Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts. A falling path with non-zero shifts is a choice of exactly one element from each row of grid such that no two elements chosen in adjacent rows are in the same column.

Source: Minimum Falling Path Sum II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
grid = [[1,2,3],[4,5,6],[7,8,9]]
Output
13

# Example 2

Input
grid = [[7]]
Output
7

Constraints

n == grid.length == grid[i].length
1 <= n <= 200
-99 <= grid[i][j] <= 99

Related LeetCode Problems

Practice more problems similar to Minimum Falling Path Sum II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.