Given m and n, return the number of monotonic paths from the top-left to the bottom-right of an m x n grid using only right and down moves. Pattern focus: Space optimization. Solve the classic Unique Paths problem with a rolling array or 1D DP.
m and n are the grid dimensions
number of monotonic paths
Example 1:
Input:
m = 4 n = 5
Output:
35
Explanation:
A 4x5 grid has 35 monotonic paths.
Example 2:
Input:
m = 5 n = 5
Output:
70
Explanation:
A 5x5 grid has 70 monotonic paths.
Example 3:
Input:
m = 2 n = 6
Output:
6
Explanation:
A 2x6 grid has 6 paths.