Flood Fill
BFS or DFS on a grid, treating same-coloured neighbours as edges.
Flood Fill: Fill a region
Pop (0, 0). 2 neighbours still land: (1, 0), (0, 1). Paint and queue them.
Cost
- Best
- O(r * c)
- Average
- O(r * c)
- Worst
- O(r * c)
- Space
- O(r * c)
Before this
Leads to
Topics that need this one first.
Taught by the same lesson
Flood Fill covers these too, in the same run.