You are given two integers m and n representing the number of rows and columns of a grid. A robot starts at the top-left cell (0, 0) and wants to reach the bottom-right cell (m-1, n-1).
The robot can only move:
Right (R)
Down (D)
Your task is to calculate the total number of unique paths the robot can take to reach the destination. Return the total number of possible paths.
Example 1
Input: m = 1, n = 1
Output: 1
Explanation: The robot is already at the destination.
Example 2
Input: m = 2, n = 2
Output: 2
Explanation: The robot can go Right?Down or Down?Right.
Example 3
Input: m = 3, n = 3
Output: 6
Explanation: Different combinations of right and down moves lead to 6 distinct paths.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
2 2
2
2 3
3