FastPrepUnique Paths Through a Grid
Problems/Unique Paths Through a Grid

Unique Paths Through a Grid

PeopleStrong logoPeopleStrong● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a PeopleStrong written online assessment. The report names unique paths in a matrix but leaves out the movement and obstacle rules. We chose moving only right or down on an open grid, plus the function interface. Our version is about 85% the same as the reported question.

Given the number of rows m and columns n in a rectangular grid, count the distinct paths from the top-left cell to the bottom-right cell.

For this exercise, assume every cell is open and each move goes exactly one cell right or one cell down. Paths are distinct when their sequences of visited cells differ. Return the exact count as a 64-bit integer.

Function

uniquePaths(m: int, n: int) → long

Examples

Example 1

m = 3n = 4return = 10

Each path contains two down moves and three right moves. Choosing the two down positions among five moves gives 10 paths.

Example 2

m = 1n = 5return = 1

There is only one row, so the only path moves right four times.

Constraints

  • For this exercise, assume 1 <= m, n <= 20.
  • No blocked cells or other movement directions are part of this exercise.
  • The result fits in a signed 64-bit integer.

More PeopleStrong interview questions

  • Reverse Linked-List Nodes in Groups of KOA · PHONE SCREEN · Seen Mar 2026
  • Aggressive CowsOA · Seen Oct 2021
  • Shortest Path in an Unweighted GraphOA · Seen Oct 2021
  • Total Set Bits from 1 to NOA · Seen Oct 2021
  • Swap Two Array ElementsOA · Seen Sep 2021
  • Minimum Travel Time with Flashing Traffic LightsOA · Seen Aug 2021
  • Permutation in a StringOA · Seen Aug 2021
  • Rat in a Maze: All Simple PathsOA · Seen Aug 2021
  • Add Two Binary StringsONSITE INTERVIEW · Seen Mar 2026
  • Four SumONSITE INTERVIEW · Seen Mar 2026

Similar questions at other companies

  • Frog Paths Without Long RunsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Count Lucky TicketsThe D.E. Shaw Group · OAThe D.E. Shaw Group interview questions
  • Maximum Score with Prime JumpsMicrosoft · OAMicrosoft interview questions
  • Jump Game with Prime-Step RuleUber · OAUber interview questions
  • Count Shipment SchedulesMorgan Stanley · OAMorgan Stanley interview questions
  • Get Minimum OperationsJP Morgan Chase · OAJP Morgan Chase interview questions
  • Jump Game with Prime-3 StepsAgoda · OAAgoda interview questions
  • Find Encrypted NumberAmazon · OA
  • Prime StringSnowflake · OASnowflake interview questions
  • Valid PasswordsMathWorks · OAMathWorks interview questions

Interview reports that mention this question

  • PeopleStrong SDE OA and Interview Questions: 12 Experiences
All PeopleStrong interview questionsSee PeopleStrong hiring insights
Saved
class Solution {
    public long uniquePaths(int m, int n) {
        // Write your solution here.
    }
}
Checking account…