/62. Unique Paths

62. Unique Paths

Medium
Probability66.6% acceptance

Given two positive integers row_count and column_count representing the dimensions of a grid, compute the number of distinct paths from the cell at (0, 0) to the cell at (row_count-1, column_count-1), where movement is restricted to only right or down at each step.

Example 1

Input: row_count=4, column_count=5

Output: 35

Explanation: There are 35 distinct paths from (0,0) to (3,4) moving only right or down.

Example 2

Input: row_count=2, column_count=2

Output: 2

Explanation: There are 2 distinct paths: right->down or down->right.

Constraints

  • 1 <= row_count <= 100
  • 1 <= column_count <= 100
  • The result will be less than or equal to 2 * 109
Python (current runtime)

Case 1

Input: row_count=5, column_count=3

Expected: 15

Case 2

Input: row_count=6, column_count=1

Expected: 1

Case 3

Input: row_count=1, column_count=8

Expected: 1

Case 4

Input: row_count=7, column_count=4

Expected: 84