FastPrepUnique Paths

Unique Paths

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN
Learn

Problem statement

A robot starts in the top-left cell of a rows x columns grid and may move only one cell right or one cell down. Return the number of distinct paths to the bottom-right cell.

Function

uniquePaths(rows: int, columns: int) → int

Examples

Example 1

rows = 3columns = 7return = 28

Every path uses two down moves and six right moves.

Example 2

rows = 1columns = 5return = 1

A one-row grid has only the all-right path.

Constraints

  • 1 <= rows, columns <= 20.
  • The answer fits in a signed 32-bit integer.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int uniquePaths(int rows, int columns) {
    // Write your code here.
}
rows3
columns7
expected28
Checking account…