Given two integers m and n, return the number of monotonic paths from the top-left corner to the bottom-right corner of an m x n grid when only right and down moves are allowed. Pattern focus: Unique paths. Design a solution that works for large grids and avoids redundant recomputation.
m and n are the grid dimensions
number of monotonic paths
Example 1:
Input:
m = 3 n = 7
Output:
28
Explanation:
Classic 3x7 grid has 28 monotonic paths.
Example 2:
Input:
m = 3 n = 2
Output:
3
Explanation:
A 3x2 grid has 3 ways to reach the bottom-right.
Example 3:
Input:
m = 1 n = 5
Output:
1
Explanation:
A single row has exactly one path.