PIXELBANKv9.1.0
Menu

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 m−1=2m - 1 = 2 moves down and n−1=6n - 1 = 6 moves right, for a total of m+n−2=8m + n - 2 = 8 moves.
  • The number of unique paths is equivalent to choosing m−1=2m - 1 = 2 moves down out of the total 88 moves, which can be calculated using the binomial coefficient: (82)=8!2!(8−2)!=8â‹…72=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 locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Unique Paths - Medium | PixelBank