Diwali Offer!Flat 20% OFF
Enroll Now
PrakalpanaLive online tech training

170. Unique Paths

MediumDay 49 of 60Dynamic Programming

A robot starts 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 one cell at a time. Return the number of different paths it can take.

Example 1
Input: m = 3, n = 7
Output: 28
Example 2
Input: m = 3, n = 2
Output: 3
Right then down then down, down then right then down, or down then down then right.
Constraints
  • 1 <= m, n <= 100
  • The answer is at most 2 * 10^9
Hints
Frequently asked at: Amazon, Google, Goldman Sachs, Bloomberg
Ctrl + Enter runs the examples

Not sure what to learn next?

A 1-on-1 session with an industry mentor and a roadmap built for you. How it works

  1. 1Discuss your goals
  2. 2Get a personal plan
  3. 3Start learning
Book for β‚Ή200/ 30 min