Minimum Falling Path Sum
Updated
Problem statement
Given a rectangular integer matrix, choose any cell in the top row. On each next row, move down-left, straight down, or down-right.
Return the minimum sum of a path that reaches the final row.
Function
minimumFallingPathSum(matrix: int[][]) → longExamples
Example 1
matrix = [[2,1,3],[6,5,4],[7,8,9]]return = 13The path 1 → 5 → 7 has sum 13.
Example 2
matrix = [[-19,57],[-40,-5]]return = -59Choose -19, then move down to -40.
Example 3
matrix = [[5]]return = 5The only cell is both the top and final row.
Constraints
1 <= matrix.length, matrix[i].length <= 1000.- All rows have the same length.
-1000000000 <= matrix[i][j] <= 1000000000.- The answer fits in a signed 64-bit integer.
More Scale AI Online Assessment questions
- Part 2: Batch Access ReviewOA · Seen Nov 2026
- Part 1: The Narrowest KeyOA · Seen Nov 2026
- Build Sessions from Unordered Events (Part 1)OA · Seen Oct 2026
- Match Billing Charges to User Sessions (Part 2)OA · Seen Oct 2026
- Four-Player Trick-Taking Card Game SimulationOA · PHONE SCREEN · Seen Aug 2026
- Free Windows Between Busy IntervalsOA · PHONE SCREEN · Seen Apr 2026
- Compare Labeling Worker AnnotationsOA · Seen Mar 2025
- Count Stable Server SubsegmentsOA · Seen Nov 2024
- Distinct OR Values of Increasing SubsequencesOA · Seen Nov 2024
- Running Through Walls with Limited EnergyOA · Seen Sep 2024
Similar questions at other companies
- Grid Paths with Override PassesIMC Trading · OAIMC Trading interview questions
- Largest Square of OnesOpenAI · OAOpenAI interview questions
- Grid Paths with Override PassesMicrosoft · OAMicrosoft interview questions
- Minimum Moves to Spread Stones Across a GridAmerican Express · OAAmerican Express interview questions
- Maximum Reward (Intuit India)Intuit · OAIntuit interview questions
- Largest Plus SignxAI · OAxAI interview questions
- Calculate the Max ValueAmazon · OA
- Largest Square of 1'sFactSet · OAFactSet interview questions
- Longest Border-Ending Diagonal PatternZipRecruiter · OAZipRecruiter interview questions
- Count Grid Words with One TurnCapital One · OACapital One interview questions