FastPrepCount Paths from the Top Left to the Bottom Right
Problems/Count Paths from the Top Left to the Bottom Right

Count Paths from the Top Left to the Bottom Right

Amazon logoAmazon● MediumNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Amazon Experience 49 clearly gives the task of counting all the ways to go from the top-left to the bottom-right of a grid. It was an onsite interview. The report gives no function signature or limits. So we use the usual rule that you move only right or down, and we keep results within 64-bit range. Our version is about 95% the same as the reported question.

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) → long

Examples

Example 1

rows = 3columns = 4return = 10

Every path contains two down moves and three right moves; there are 10 orderings.

Example 2

rows = 1columns = 7return = 1

Only repeated right moves are possible.

Example 3

rows = 5columns = 5return = 70

There 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
See Amazon hiring insights
Saved
class Solution {
    public long countGridPaths(int rows, int columns) {
      // write your code here
    }
}
Checking account…