Paths Subjects Questions Quizzes Pricing Search
Beginner Open Pro

Matrix Pathways

There is a robot on an m x n grid, initially at the top-left corner (grid[0][0]). The robot can only move either down or right at any point, and it is trying to reach the bottom-right corner (grid[m-1][n-1]). Return the number of unique paths from the top-left to the bottom-right corner.

Example 1

Input: m = 3, n = 7
Output: 28

Example 2

Input: m = 3, n = 2
Output: 3
Explanation: From top-left, there are 3 ways to reach
bottom-right: Right->Down->Down, Down->Right->Down,
Down->Down->Right.

Constraints

  • 1 <= m, n <= 100

Share this question

← Back to Dynamic Programming practice

We use cookies for product analytics to improve OmniAtlas. See our Privacy Policy.