Study
Which Grid BFS Questions Are Candidates Reporting in 2026?
TrueInterview
October 19, 2026 · 16 min read

As of 2026-10-19, TrueInterview's bank holds 38 grid BFS and flood-fill questions reported at 15 big-tech companies, and 36 of them were last reported in the 12 months before that date. The most-linked entries are not the plain island count: Number of Islands II (8 write-ups, Uber and Google) leads, followed by Number of Islands and Grid BFS Variants (7, Amazon and ByteDance) and Meta's Maze Problem (5). Treat a clean Number of Islands as the opening move rather than the question. Your grid preparation should end in union-find and BFS shortest path, not in one more flood-fill count.
Disclosure: TrueInterview is an interview-preparation product and publishes this article. Facts about other products come from their public pages on the dates listed under Sources.
Which grid variants do candidates write up most?
Eight entries carry most of the write-up links, and only one of them is the LeetCode 200 problem under its own name. The dynamic Number of Islands II and Meta's maze titles sit at the top, with follow-up and shape variants below them. The counts are what candidates wrote up, not how often a company asks, and the list is not any company's official question set.
| Question | Companies in the write-ups | Write-up links | Practise |
|---|---|---|---|
| Number of Islands II | Uber, Google | 8 | Number of Islands II |
| Number of Islands and Grid BFS Variants | Amazon, ByteDance | 7 | Grid BFS Variants |
| Maze Problem | Meta | 5 | Maze Problem |
| Maze Path Finding | Meta | 3 | Maze Path Finding |
| Number of Distinct Islands | ByteDance, Google | 3 | Number of Distinct Islands |
| Mouse and Cheese / Maze Rewards | Meta | 3 | Mouse and Cheese / Maze Rewards |
| Number of Islands (LC 200) | Oracle | 3 | Number of Islands |
| Number of Islands and Island Perimeter | Amazon | 3 | Island Perimeter variant |
By company, Meta files the most grid questions (10), followed by Uber (9), Google (7), Amazon (6) and ByteDance (6), with Snapchat and Oracle at 4 each. Breadth and depth disagree on one entry: Number of Islands (Plain and Streaming) is filed under 7 big-tech companies, Uber, Amazon, ByteDance, Google, LinkedIn, Microsoft and Snapchat, yet no candidate write-up links to it. Filing shows a question has been reported widely; links show how candidates described the round around it.
Our take: the top of this table argues against one more pass over the base problem. Several of the most-linked titles build on the plain count (Number of Islands II, Grid BFS Variants, Island Perimeter), while Meta's top titles are mazes. Spend a single session confirming your base solution, then put the rest of your grid time into the variant your target company files.
How have the reported variants moved past the plain count?
The dated examples show three directions beside the plain count: land that arrives over time, island shapes and boundaries, and grids that change by rule each step. These are last-reported dates on single examples, not a time series, so read them as a map of what candidates are seeing now rather than as a measured rise.
| Company | Question | Round | Last reported |
|---|---|---|---|
| Uber | Number of Islands II | Phone screen | 2026-10 |
| Amazon | Number of Islands with Max-Area and Streaming-Rows Follow-Ups | Onsite | 2026-10 |
| Oracle | Number of Islands (LC 200) | Phone screen | 2026-09 |
| ByteDance | Number of Islands and Grid BFS Variants | Phone screen | 2026-08 |
| OpenAI | Cell Simulation / Conway's Game of Life | Phone screen | 2026-06 |
| Meta | Maze Problem | Phone screen | 2026-05 |
| Snapchat | Count Islands and Water Boundary | Phone screen | 2026-04 |
| Airbnb | Compute maze score using shortest path | Onsite | 2026-03 |
| Number of Distinct Islands | Phone screen | 2026-01 | |
| Lyft | Minesweeper Game Logic | Onsite | 2025-10 |
TrueInterview's homepage also lists two October 2026 reports that fit the third direction and a harder connectivity twist: Plant Infection Spread: Days Until Stable at Apple, rated Medium, and Connected Crop Arrangement on a Grid at Google, rated Hard. The most recent plain-count entry in the table is Oracle's, and it sits among dynamic, follow-up and simulation entries from the same months. If your loop is in the next month, prepare for the version with a second part.
Is a grid question more likely in the phone screen, onsite or OA?
The phone screen, by a wide margin. These questions were reported in phone screens 24 times, onsites 15 times and online assessments 5 times, and a question can appear in more than one round. In our view, aim for a fast, bug-free base count in a phone screen so you have time left if the interviewer adds a follow-up.

Tags do not separate the rounds. Graphs (21) and matrix (12) lead the phone-screen questions, and graphs (13) and matrix (11) lead the onsite ones. The onsite examples in the dated table lean toward multi-part prompts and simulations: Amazon's max-area and streaming-rows question, Airbnb's maze score and Lyft's Minesweeper. techinterview's guide makes the general point about follow-ups: "What separates a strong loop from a forgettable one is everything the interviewer asks after that."
Our take: if your next round is a phone screen, rehearse the base count until it takes no thought, then practise one variant under the same timer. If it is an onsite, expect a grid prompt with a second or third part, and practise extending one solution rather than writing three separate ones.
How do you solve Number of Islands II, the variant to own?
Use union-find. Number of Islands II is the most-linked grid variant in the bank, filed under Uber, Apple and Google, and its latest report places it in an Uber phone screen in 2026-10. techinterview's guide describes it as LeetCode 305, where land appears one position at a time and you report the island count after each addition.
The first idea, a fresh flood fill after every addition, is the one to name and reject. techinterview's guide says rerunning DFS or BFS after every operation costs O(k times rows times cols) for k additions, "and that is the answer an interviewer is hoping you will reject." The union-find version keeps a parent array over cells. Each new land cell starts as its own island and raises the count by one; for each land neighbour, a union of two different roots merges two islands and lowers the count by one. With path compression and union by rank, each addition costs close to constant time, so the whole run is near-linear in the number of additions.
Handle a position that is added twice by returning the current count without creating a second root. Count a merge only when the two roots differ, since two neighbours of the new cell can already belong to the same island.
Worked example: an Uber phone screen in three sessions
Uber files 9 grid questions in the bank, second only to Meta, and Number of Islands II is the one with the most write-ups behind it. Session one: the base count in a few minutes, stating four-way adjacency, asking whether you may modify the grid, and marking cells as you enqueue them in a deque. Session two: Number of Islands II, saying out loud why a flood fill per addition is too slow before writing union-find. Session three: Max Area of Island and Minimum Knight Moves, which the bank also files under Uber. cp-algorithms' BFS page notes that BFS finds the solution with the fewest moves when each game state is a vertex and each transition an edge. For knight moves, that means the first time you reach the target square is the answer.
What do Meta's maze questions ask you to compute?
Shortest paths, in our reading of the titles, rather than component counts. Meta's linked grid titles are Maze Problem (5 write-ups), Maze Path Finding (3) and Mouse and Cheese / Maze Rewards (3), and Maze Problem was last reported in a Meta phone screen in 2026-05. If you interview at Meta, make BFS shortest path your main grid session.
The titles say maze, path and reward; what each one asks beyond that is our interpretation, so practise the general technique rather than a guessed prompt. cp-algorithms' BFS page states that the path BFS finds is "the shortest path to that node, i.e the path that contains the smallest number of edges in unweighted graphs." Red Blob Games' pathfinding guide adds two practical moves: keep a came_from record for every reached cell so you can rebuild the path, and stop expanding as soon as you reach the goal when only one target matters.
The interviewer's likely push is on costs. If moves carry different costs, the Red Blob Games guide says to switch to Dijkstra's Algorithm, and cp-algorithms' page notes that 0 or 1 edge weights need only a small change to BFS. Airbnb's onsite title, Compute maze score using shortest path, shows the same technique outside Meta. A reward-collecting maze such as Mouse and Cheese may need state beyond the cell, such as which rewards are already collected; in our view, say that state out loud before you code.
Where does the rotting-oranges pattern show up now?
In spread simulations, in our reading of the titles. None of the reported titles in this article uses the rotting-oranges name, but Infection Spread Simulation and Plant Infection Spread read as the same level-by-level BFS. TrueInterview's catalog lists Infection Spread Simulation under OpenAI and Anthropic in the phone screen, tagged BFS and simulation at medium difficulty.
Apple's Plant Infection Spread asks for the days until the grid is stable, which we read as a count of BFS levels; the catalog tags do not say multi-source. OpenAI's Cell Simulation / Conway's Game of Life is a different shape: every cell updates from its neighbours each step, so the work is a double-buffered update rather than a queue. cp-algorithms' page gives the picture to keep in mind for the BFS kind: "The algorithm can be understood as a fire spreading on the graph".
To practise, seed the queue with every infected cell at once, process the queue one level at a time, and count levels until a level adds nothing. Then check the edge case where some healthy cell is unreachable, and decide with the interviewer whether that returns a sentinel value or the last level reached.
What follow-ups do Amazon and ByteDance attach to the island count?
Area, perimeter, shape and streaming input. Number of Islands and Grid BFS Variants is linked from 7 write-ups at Amazon and ByteDance, with a ByteDance phone-screen report from 2026-08. TrueInterview lists the Amazon onsite version, Number of Islands with Max-Area and Streaming-Rows Follow-Ups, as a Medium coding question from October 2026.
Expect area as the first add-on. techinterview's guide lists the largest-island follow-up as LeetCode 695, "the same flood fill while you tally cells per component and keep the max." Number of Islands and Island Perimeter is filed under ByteDance, Amazon and Microsoft. For streaming rows, keep only the previous row's labels and merge components as each new row arrives, which in our view is where union-find earns its place a second time.
The shape variants are Number of Distinct Islands at ByteDance and Google, last reported in a Google phone screen in 2026-01, and Count Islands and Water Boundary, filed under 2 companies and linked from 3 write-ups. For distinct shapes, record each island's cells relative to its first cell and store the normalised list in a set.
Diagonal adjacency changes the graph itself. PracHub's guide says that if the interviewer changes adjacency to eight neighbours, "that is a different graph even though the input looks identical." techinterview's guide adds that the change "quietly checks whether your direction list lives in one place or is copy-pasted across the code." Wikipedia's flood-fill article names the same split as four-way and eight-way fill. One author on Medium describes a Google onsite version where cells connect horizontally, vertically or diagonally; that is one person's account, not bank data.
Should you use BFS, DFS or union-find on a grid?
Pick by the output the prompt asks for. BFS gives shortest paths and level counts, BFS or iterative DFS counts components, and union-find handles land that arrives over time. cp-algorithms' BFS page notes that BFS finds all connected components of an undirected graph in O(n + m) time, so the choice is about follow-ups, not speed.
| Criterion | BFS with a deque | Iterative DFS | Recursive DFS | Union-find |
|---|---|---|---|---|
| Shortest path or level count | Yes | No | No | No |
| Component count on a fixed grid | Yes | Yes | Yes, if depth is safe | Yes |
| Land added over time | Rerun per addition | Rerun per addition | Rerun per addition | Yes |
| Risk on a large all-land grid | Queue memory | Stack memory | Stack overflow | Parent array memory |
| Best for | Mazes, spread simulations, knight moves | Counting when order does not matter | Short code on small grids | Number of Islands II, streaming rows |
Before you write code, state the two contracts PracHub's guide names: "which cells count as neighbors, and whether the solution may modify the input." techinterview's guide says some interviewers want the grid left intact, so ask before sinking land. If you copy instead, PracHub's guide warns: "An outer copy such as grid[:] is insufficient because it still references the original row lists."
The base-solution bugs to remove
- Marking too late. techinterview's guide says to "mark a cell visited when you enqueue it, not when you dequeue it." and calls the opposite the single most common BFS bug on this problem.
- Counting the wrong thing. PracHub's guide says to increment once per previously undiscovered land root, never per neighbour or queue entry.
- Recursion depth. techinterview's guide warns that depth can reach O(rows times cols) on one snaking component and overflow the stack on a million-cell grid. Wikipedia's flood-fill article says moving the recursion into a stack or queue prevents the overflow.
- Slow pops. PracHub's guide advises a deque so removing the next cell does not shift the frontier.
- Bounds and types. PracHub's guide warns that a missing lower-bound check in Python can connect opposite edges, and that comparing strings with integer cells can return zero without visiting any land.
- Shared test grids. PracHub's guide warns that a test reusing a grid consumed by a destructive DFS can return zero for the wrong reason.
What changes at senior and staff level?
The topic as a whole draws more junior links, while the largest per-question senior counts are on Number of Islands II and Meta's Maze Problem, in a small sample. Write-ups link these questions 26 times from candidates who reported a senior, staff-plus or manager level and 35 times from those who reported junior, new-grad or intern. Levels are what candidates stated on their own write-ups, and the per-question counts below are a handful of links each, so read them as a direction rather than a measured lean.
| Question | Senior-or-above links | Junior-or-below links |
|---|---|---|
| Number of Islands II | 5 | 3 |
| Maze Problem | 4, one staff-plus or manager | 1 |
| Mouse and Cheese / Maze Rewards | 2 | 1 |
| Number of Islands (LC 200) | 2 | 1 |
| Minimum Knight Moves | 1 of 1 | 0 |
| Max Area of Island | 1 of 1 | 0 |
| Number of Islands and Island Perimeter | 0 of 3 | Not stated |
Our take: in our view, at senior level the base count is assumed, and you are judged on noticing that the input has become dynamic and choosing union-find without being led there. techinterview's guide makes the same point about the second half of a slot that opens with the basic count: "reaching for DSU before they ask is the move that reads as experience." That is one guide's view, not bank data, and the level counts above neither confirm nor refute it: senior candidates also wrote up the base LeetCode 200 entry, which suggests the base count still gets asked, while the dynamic and maze variants hold more of the senior links. If you are senior, give the dynamic and maze variants your longer sessions and keep perimeter-style follow-ups as short drills.
Down-leveling note (our view): in this topic, the down-level risk is a round that ends at the base count. If an interviewer opens with the island count and adds a dynamic or shortest-path second part, finishing only the first part leaves no evidence of the judgement a senior loop looks for, so budget your phone-screen time to reach the second part.
How we counted
Counts come from TrueInterview's question bank as of 2026-10-19 and cover the grid BFS and flood-fill coding questions described above. A question can be filed under several companies and reported in several rounds, so tallies overlap. Write-up links count candidate write-ups that point to a question, split by the level each candidate reported; filings and links measure different things, and neither is how often a company asks.
FAQ
What are the common Number of Islands interview variations?
The variants with the most write-up links are the incremental Number of Islands II, Grid BFS Variants, Meta's maze titles, Distinct Islands and the perimeter variant. Reported follow-ups on the same grid also include largest island area, water boundaries and rows that arrive one at a time. Diagonal adjacency is a smaller twist that tests whether your neighbour rule lives in one place. Spread simulations, which in our reading are multi-source BFS, appear under their own titles. Start from the ranked table at the top of this page and pick the entry your target company files, rather than working through every variant in order.
How do you solve Number of Islands II efficiently?
Use union-find over the cells. Each added land cell starts as a new island, and each union with a land neighbour that has a different root merges two islands, so you adjust the count by one per event and report it after every addition. Name the rejected approach first: rerunning a flood fill after every addition repeats work across the whole grid. Guard against the same position being added twice, and use path compression with union by rank so each addition stays close to constant time.
How is Number of Distinct Islands different from counting islands?
It asks how many island shapes are distinct, not how many islands exist. Two islands with the same shape in different places count once. The standard approach is to run the usual flood fill, record each cell's offset from the island's first cell in a fixed visiting order, and add that normalised signature to a set; the set's size is the answer. Decide early with the interviewer whether rotations and reflections count as the same shape, since that changes the signature you need to build.
How do you find the max area of an island?
Run the same flood fill you use for counting, but return the number of cells in each component and keep the largest. Nothing else changes: the neighbour rule, the visited marking and the scan stay the same. This is why the area follow-up is a test of whether your base solution is structured cleanly. If your flood fill returns a size rather than nothing, the follow-up is a one-line change, and the perimeter follow-up becomes a matter of counting edges that touch water or the border.
Is Number of Islands asked in the phone screen or the onsite?
Both. The round counts above cover the whole grid topic rather than this one problem, but the named island examples sit on both sides: Oracle's LeetCode 200 entry was last reported in a phone screen in 2026-09, and Amazon's max-area and streaming-rows version in an onsite in 2026-10. The onsite example is the multi-part one. If your phone screen is next, aim for a bug-free base count with time left for a follow-up; if the onsite is next, practise extending one grid solution through two or three follow-up questions in a single session.
Should I use BFS or DFS for grid problems?
Use BFS when the answer depends on distance or levels, which covers mazes, knight moves and spread simulations, because the first time BFS reaches a cell is the shortest route there. For plain counting, either works, but prefer BFS with a deque or an iterative DFS over recursion on large grids, since an all-land grid can make the recursion as deep as the grid is large. Switch to union-find when the grid changes over time.
Your practice plan
A three-week plan for someone working full time, about an hour on weekdays:
- Week one. Rewrite Number of Islands (LeetCode 200) iteratively with a deque, marking cells as you enqueue them, and test it on a fresh deep copy of each input grid.
- Week one. Extend the same code to Max Area of Island and the Island Perimeter variant, keeping one direction list for every version.
- Week two. Solve Number of Islands II with union-find, saying aloud why a flood fill after every addition is the approach to reject. Make this your main session if you target Uber or Google.
- Week two. If you target Meta, solve Maze Problem and Maze Path Finding as BFS shortest path with a came_from record and an early exit at the goal.
- Week two. If you target Amazon or ByteDance, solve Number of Islands with Max-Area and Streaming-Rows Follow-Ups and Grid BFS Variants back to back on the same grid.
- Week three. Solve Number of Distinct Islands and Minimum Knight Moves, then one spread simulation with multi-source BFS that counts levels.
- Week three. Re-solve your week-two variant under a phone-screen timer, finishing the base count first and leaving most of the slot for the follow-up.
Sources
- TrueInterview question bank — grid BFS and flood-fill at big-tech companies — counted 2026-10-19
- Real FAANG Interview Questions by Company · TrueInterview — checked 2026-10-19
- Number of Islands solved three ways, and the follow-ups – techinterview — checked 2026-10-19
- Breadth First Search - Algorithms for Competitive Programming — checked 2026-10-19
- Introduction to the A* Algorithm — checked 2026-10-19
- Coding Interview Questions by Company · TrueInterview — checked 2026-10-19
- Number of Islands: Flood Fill, Input Mutation, and Connectivity Rules | PracHub Knowledge Hub — checked 2026-10-19
- Flood fill - Wikipedia — checked 2026-10-19
- Medium — checked 2026-10-19
Last reviewed: 2026-10-19.