FastPrepCount Bounded Diagonal Grid Paths
Problems/Count Bounded Diagonal Grid Paths

Count Bounded Diagonal Grid Paths

Google logoGoogle● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A phone-screen report describes a grid with limits, three allowed moves to the next column, a destination, and a second count that must pass through one cell. Here the function returns both counts in a two-element array.

Start at cell (0, 0) in a grid with width columns and height rows. Every move advances to the next column and changes the row by -1, 0, or 1; moves outside rows 0 through height - 1 are invalid. Return two counts: all paths that end at (width - 1, 0), and the paths among them that pass through (passX, passY).

Function

countBoundedGridPaths(width: int, height: int, passX: int, passY: int) → long[]

Examples

Example 1

width = 4height = 3passX = 1passY = 1return = [4,2]

There are four bounded paths to the destination, and two of them pass through row one in column one.

Example 2

width = 1height = 1passX = 0passY = 0return = [1,1]

The empty path is the only route and passes through the single cell.

Constraints

  • 1 <= width <= 30
  • 1 <= height <= 30
  • 0 <= passX < width
  • 0 <= passY < height
  • both returned counts fit signed 64-bit integers

More Google Phone Screen questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026

Similar questions at other companies

  • Unique Grid PathsMorgan Stanley · PHONE SCREENMorgan Stanley interview questions
  • Count Starts Reaching a Grid MaximumDuolingo · PHONE SCREENDuolingo interview questions
  • Find Robots by Blocker DistancesUber · PHONE SCREENUber interview questions
  • Factory Cost — Minimum Cost Across StagesStripe · PHONE SCREENStripe interview questions
  • Path Through an O/X Grid Using Only Right and DownAmazon · PHONE SCREEN
  • 3D Grid Diagonal Walk ProbabilityApple · PHONE SCREENApple interview questions
  • Maximum Rocks on a North-or-East Grid PathGoldman Sachs · PHONE SCREENGoldman Sachs interview questions
  • Maximal SquareAirwallex · PHONE SCREENAirwallex interview questions
  • Maximal SquareSalesforce · PHONE SCREENSalesforce interview questions
  • Maximum Grid Path ScoreDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
  • Google Experienced SWE First Round and Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public long[] countBoundedGridPaths(int width, int height, int passX, int passY) {
        // Write your code here.
    }

}
Checking account…