InterviewLegend

Grid BFS & Flood Fill

Alex Chen26 min readUpdated 309 real interview reports

Graph problems at Intuit usually come as grids. The intern Glider OA has used a spreading-virus grid more than once, where the virus spreads to its four neighbors each second. An SDE-2 phone screen asked something close to it, with produce in place of cells. Sizing the biggest connected region has come up in a video round and in an intern first round that went on to flipping one cell. Finding which cells can reach both borders of a map came up in an Assessor round for an experienced backend hire, run on Glider against hidden tests.

Counting regions on a grid is covered in Trees & Graphs, and these three problems build on the same traversal. The virus problem starts from many cells at once and measures time. For the region problem you return how big each region is instead of how many there are. On the two-border problem you turn the question around and flood inward from the edges of the map. Neighbors and visited marks stay the same in all three, and what changes is how you read the result.

The Intuit angle
Grid answers at Intuit run against hidden tests, so name the edge cases before you write the loop. In one Assessor round the two-border problem was scored in a set order, a brute force first, then the optimization, then the edge cases, all against tests on Glider. For every grid, check a single row, a single cell, a grid with nothing to spread from, and a diagonal pair that must stay apart. Then be ready for the recursion question. A flood fill on a solid grid of a million cells needs a million stack frames, which a default Java stack won't hold, so know the explicit-stack or queue version too.

IntuitPremium lesson · Coding round

The 3 Intuit problems are below.

  1. A Premium questionCoding · Medium · Frequently asked
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

Each with hints, the follow-up and a tested solution.

Get the Intuit questions

$49 a year · all 100 companies · cancel anytime

From 309 Intuit reports, forum threads behind logins and write-ups in Chinese.

Had your Intuit interview?Tell us what they asked. Reviewed before it goes in, never with your name.
Intuit interview guide

Know what Intuit asks before you walk in.

28 coding · 5 system design · 21 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.