PIXELBANKv8.2.1
Menu

Unique Paths

A robot on an m x n grid starts at top-left and can only move right or down. How many unique paths exist to the bottom-right?

Example:

Input:
3 7
Output:
28
Reasoning:
  • The grid size is determined by the input values, with m=3m = 3 rows and n=7n = 7 columns.
  • To reach the bottom-right corner, the robot must make m1=2m - 1 = 2 moves down and n1=6n - 1 = 6 moves right, for a total of m+n2=8m + n - 2 = 8 moves.
  • The number of unique paths is equivalent to choosing m1=2m - 1 = 2 moves down out of the total 88 moves, which can be calculated using the binomial coefficient: (82)=8!2!(82)!=872=28\binom{8}{2} = \frac{8!}{2!(8-2)!} = \frac{8 \cdot 7}{2} = 28.
  • The final output is the result of this calculation, which represents the total number of unique paths to the bottom-right corner.

Constraints:

  • 1 <= m, n <= 100
Editor

Test Results

0/0
Run code to see test results.