773. Unique Paths in Grid (Recursive, Modulo 10^9+7)

MediumRecursionRecursion

A robot is located at the top-left corner of an m x n grid. It can move either DOWN or RIGHT at each step. Return the number of possible unique paths from the top-left to the bottom-right, taken modulo 10^9 + 7. Implement recursively.

Input: Two positive integers m and n separated by a comma.

Output: Return an integer equal to the path count mod (10^9 + 7).

Examples

Example 1
Input: 3, 7
Output: 28
Explanation: C(m+n-2, m-1) = C(8,2) = 28.
Example 2
Input: 3, 2
Output: 3
Explanation: Three paths in a 3x2 grid.
Example 3
Input: 1, 1
Output: 1
Explanation: Trivial single-cell path.

Constraints

Asked by

AmazonMicrosoftGoogleAdobeFlipkart
Solve this problem in the editor →