Practice · 3 of 5
Flood Fill Rooms
CHALLENGE
Difficulty: intermediate+25 XP
**Description:** A grid of '.' (open) and '#' (wall) cells. Two open cells are in
the same room if connected horizontally or vertically. Count the rooms.
**Input:** Line 1: n m (1 <= n, m <= 1000). Next n lines: m characters each.
**Output:** One integer — the number of rooms.
**Example:** 3 4 / .#.. / .#.# / .#.. -> 2.
Press Submit to check your solution.
Back to lesson: Practice: Graph Theory Problem Set