Problem · Matrix
Binary Matrix Top-to-Bottom Reachability
Problem statement
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.
The problem statement continues
ProExamples
Example 1
grid = [[0,1,1],[0,0,1],[1,0,0]]return = trueOne valid route is (0,0) -> (1,0) -> (1,1) -> (2,1). It reaches an open bottom-row cell.
FastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$9/month
Pro subscription, billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week