FastPrepBinary Matrix Top-to-Bottom Reachability
Problems/Binary Matrix Top-to-Bottom Reachability

Binary Matrix Top-to-Bottom Reachability

Google logoGoogle● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report describes reaching the bottom row from the top row of a grid. It does not say how you may move or what blocks you. Our version is about 90% the same as the reported question.

You are given a rectangular binary matrix grid. A cell with value 0 is open, and a cell with value 1 is blocked.

You may start at any open cell in the top row. From an open cell, you may move one cell up, down, left, or right, staying inside the matrix and never entering a blocked cell.

Return true if at least one open cell in the bottom row is reachable from an open cell in the top row. Otherwise, return false.

Function

canReachBottom(grid: int[][]) → boolean

Examples

Example 1

grid = [[0,1,1],[0,0,1],[1,0,0]]return = true
grid
012001110012100

One valid route is (0,0) -> (1,0) -> (1,1) -> (2,1). It reaches an open bottom-row cell.

Example 2

grid = [[0,1,0],[1,1,1],[0,0,0]]return = false
grid
012001011112000

The blocked middle row separates every open top-row cell from the bottom row.

Example 3

grid = [[1,0,1]]return = true
grid
0120101

The only row is both the top and bottom row. Its open cell is already a valid destination.

Constraints

  • 1 <= grid.length <= 500
  • 1 <= grid[i].length <= 500
  • Every row has the same length.
  • Every cell is either 0 or 1.
  • A move changes the row or column by exactly 1, but not both.

More Google Onsite Interview questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Distinct Subset SumsONSITE INTERVIEW · Seen Nov 2026
  • Playlist With No Same Artist in a RowONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Delete Nodes and Return Forest RootsONSITE INTERVIEW · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • First and Last Target Position in a Mountain ArrayONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • 0/1 Knapsack with Weight and Volume LimitsONSITE INTERVIEW · Seen Nov 2026
  • Batched Subsequence Word MatchesONSITE INTERVIEW · Seen Nov 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Mouse and Cheese ReachabilityMeta · ONSITE INTERVIEWMeta interview questions
  • Number of IslandsTripjack · ONSITE INTERVIEWTripjack interview questions
  • Number of IslandsTekion · ONSITE INTERVIEWTekion interview questions
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Number of IslandsBloomberg LP · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Number of IslandsCrowdstrike · ONSITE INTERVIEWCrowdstrike interview questions
  • Max Area of IslandRoku · ONSITE INTERVIEWRoku 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 boolean canReachBottom(int[][] grid) {
        // Write your code here.
    }
}
Checking account…