Number of Paths in a Matrix

Given an m x n matrix, return the number of ways to travel from the top-left cell to the bottom-right cell using only right and down moves. Pattern focus: Unique paths. This is the classic path-counting formulation often solved with DP or combinatorics.

Input Format

m and n are the matrix dimensions

Output Format

number of monotonic paths

Constraints

  • 1 <= m, n <= 1000

Examples

Example 1:

Input:

m = 2
n = 3

Output:

3

Explanation:

A 2x3 matrix has 3 monotonic paths.

Example 2:

Input:

m = 3
n = 3

Output:

6

Explanation:

A 3x3 matrix has 6 monotonic paths.

Example 3:

Input:

m = 4
n = 4

Output:

20

Explanation:

A 4x4 matrix has 20 monotonic paths.

Loading...
Number of Paths in a Matrix - Dp Grid