1140. Count All Paths from Top-Left to Bottom-Right

EasyDynamic ProgrammingGrid DPCombinatorics

In an m x n grid, moving only right or down, count all distinct paths from the top-left cell to the bottom-right cell. The input is JSON {m, n}.

Input: JSON {m, n}.

Output: Integer — the number of distinct paths.

Examples

Example 1
Input: {"m":3,"n":3}
Output: 6
Explanation: Six monotone paths.
Example 2
Input: {"m":2,"n":2}
Output: 2
Explanation: Two paths.
Example 3
Input: {"m":1,"n":5}
Output: 1
Explanation: Only one straight path.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →