Unique Paths

A robot stands on the top-left cell of a grid with m rows and n columns. In one move it can go either one cell right or one cell down; it can never move up or left.

Return the number of different paths that take the robot to the bottom-right cell. Two paths are different if they visit a different sequence of cells.

Constraints

  • 1 <= m, n <= 100
  • The tests only use grids whose answer is at most 2 * 10^9, so it fits in a 32-bit signed integer.

Examples

Example 1

Input: m = 3, n = 3
Output: 6

Every path makes 2 moves down and 2 moves right in some order, and there are 6 such orders.

Example 2

Input: m = 2, n = 4
Output: 4

One move down and three moves right. The single down move can come first, second, third or last.

Example 3

Input: m = 1, n = 1
Output: 1

The robot already stands on the target: one path, with no moves at all.

JavaScript you'll use: Arrays: create, read, update Gotchas and debugging

/**
 * @param {number} m
 * @param {number} n
 * @return {number}
 */
function uniquePaths(m, n) {
  
}

Ctrl/⌘ + ' runs the examples, Ctrl/⌘ + Enter submits. Use console.log freely: output shows under Console. In the editor, press Esc then Tab to move focus out.