Increasing Paths, part 2
Updated
Problem statement
This is the same problem as before, except that there may be many more increasing paths, up to 20 billion. (Note this result will not fit in a 32-bit integer.)
Function
countIncreasingPaths(matrix: int[][]) → longExamples
Example 1
matrix = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], [5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19], [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21], [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], [9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25], [12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26], [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27], [14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]]return = 601079908There are 601,079,908 increasing paths.
Constraints
🍑
More Hudson River Trading interview questions
- Format a Signed Integer with CommasPHONE SCREEN · Seen Nov 2026
- Order and Batch Open-Close LifecyclePHONE SCREEN · Seen Nov 2026
- Count Palindrome Addition ChoicesOA · Seen Nov 2026
- Tilting Maze BallPHONE SCREEN · Seen Oct 2026
- Count Multiples of Three with Two SevensOA · Seen Oct 2026
- Recursively Expanded Shell Command CountsOA · Seen Oct 2026
- Rotate Matrix Regions Around the DiagonalsOA · Seen Oct 2026
- Maximum Diamond SumOA · Seen Oct 2026
- Smallest Most-Lit Street PositionOA · Seen Oct 2026
- Rearrange String by Alternating EndsOA · Seen Sep 2026
Similar questions at other companies
- Cherry PickupInfosys · OAInfosys interview questions
- Safest Shortest Path Through a GridSnowflake · OASnowflake interview questions
- Minimum Cost Path with TeleportationsAmazon · OA
- Minimum Starting Health in a GridIntuit · OAIntuit interview questions
- Largest Two Non-Overlapping Buildable SquaresAmerican Express · OAAmerican Express interview questions
- Drone Delivery with Battery Swap StationsCisco · OACisco interview questions
- Empty ShelfSquarepoint Capital · OASquarepoint Capital interview questions
- Timed Coin Collection in a 2×N GridAtlassian · OAAtlassian interview questions
- Maximum Sum RectangleDeloitte · OADeloitte interview questions
- Longest Increasing Path in a MatrixNutanix · OANutanix interview questions