Solvarch
DSA ProblemsProgressPlanRoadmapsReviewCheat SheetsCompaniesSystem DesignCS FundamentalsQuestion Bank
Theme
Problems

Unique Paths

Medium
dynamic-programmingmathcombinatorics

A robot starts at the top-left of an m × n grid and moves only right or down. How many distinct paths reach the bottom-right?

Input: one line, two integers m n. Output: the number of paths.

Example 1
Input:
3 7
Output:
28
Example 2
Input:
3 2
Output:
3

Constraints

  • 1 ≤ m, n ≤ 100
  • The answer fits in a 32-bit integer for the given tests.
Watch a video walkthrough

Run your code against the sample tests, or Submit to run the full suite.