Unique Paths

A robot starts at the top-left corner of an m × n grid (m rows, n columns) and wants to reach the bottom-right corner. Each move goes one cell right or one cell down. How many different paths are there?

The count grows quickly, so return it as a 64-bit integer.

Constraints

  • 1 ≤ m, n ≤ 25

Example 1

Input
m = 3
n = 7
Output
28
Why:

Any order of 2 downs and 6 rights: 8! / (2! × 6!) = 28.

Example 2

Input
m = 3
n = 2
Output
3
Why:

Right-down-down, down-right-down or down-down-right.

Hints

    Was this a good challenge?

    Solved by
    0
    Submissions
    0
    Accepted
    –