Skip to content
Onsite

Unique Paths

MediumP1Coding

A robot sits at the top-left corner of an m x n grid and wants to reach the bottom-right corner. It can only move right or down. Return the number of distinct paths.

Example 1

Input
m = 3, n = 7
Output
28

Example 2

Input
m = 3, n = 2
Output
3
Why
Right-Down-Down, Down-Right-Down and Down-Down-Right.

Example 3

Input
m = 1, n = 1
Output
1

Constraints

  • 1 <= m, n <= 100
  • The answer fits in a 32-bit integer for the tested sizes (at most 2 * 10^9).

Hints

Run checks the 3 visible tests, Submit all 11.