Count Paths from the Top Left to the Bottom Right
Updated
Problem statement
A robot starts in the top-left cell of a grid with rows rows and columns columns. It must reach the bottom-right cell.
From each cell, the robot may move exactly one cell right or exactly one cell down. Return the total number of distinct valid paths.
Function
countGridPaths(rows: int, columns: int) → longExamples
Example 1
rows = 3columns = 4return = 10Every path contains two down moves and three right moves; there are 10 orderings.
Example 2
rows = 1columns = 7return = 1Only repeated right moves are possible.
Example 3
rows = 5columns = 5return = 70There are 70 ways to arrange four down and four right moves.
Constraints
1 <= rows, columns <= 30.- The answer fits in a signed 64-bit integer.
More Amazon Onsite Interview questions
- Number of IslandsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Cheapest Flights Within K StopsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course SchedulePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Course Schedule IIPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Dungeon GameONSITE INTERVIEW · Seen Nov 2026
- Integer BreakONSITE INTERVIEW · Seen Nov 2026
- LFU CacheONSITE INTERVIEW · Seen Nov 2026
- LRU Cache for Query ResultsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Count Adjacent Symbol Pairs for BPEONSITE INTERVIEW · Seen Nov 2026
- First Non-Repeating CharacterOA · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- DSA Round: Maximum Score Grid PathOpenAI · ONSITE INTERVIEWOpenAI interview questions
- Unique Grid PathsMorgan Stanley · PHONE SCREENMorgan Stanley interview questions
- Count Valid A-B-C Sequences Under a Modulo-Four RuleInfosys · OAInfosys interview questions
- Knight Probability in ChessboardGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Count Staircases with Strictly Increasing StepseBay · ONSITE INTERVIEWeBay interview questions
- Longest Matrix Walk with Two-Step ComparisonsGoogle · ONSITE INTERVIEWGoogle interview questions
- Maximum All-Ones Square Side LengthOmnissa · ONSITE INTERVIEWOmnissa interview questions
- Enumerate Right-and-Down Matrix PathsOracle · ONSITE INTERVIEWOracle interview questions
- Maximal Square AreaUber · ONSITE INTERVIEWUber interview questions
- Minimum Path SumMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
Amazon interview experiences
- Amazon SWE OA with AI Coding: 1 Experience
- Amazon SWE Intern Phone Screen Interview Experience: 1 Experience
- Amazon New Grad SDE I OA and Virtual Onsite: 1 Experience
- Amazon BIE Intern SQL and Interview Questions: 17 Experiences
- Amazon Experienced SWE AI-Assisted Debugging OA: 1 Experience
- Amazon SDE II (L5) Interview Questions: 5 Experiences