A warehouse floor is divided into rows and columns of square tiles. Each tile is either damaged or usable.
Damaged tiles that share a horizontal or vertical side belong to the same repair area. Tiles that touch only at a corner are not connected.
Find the number of separate repair areas on the warehouse floor.
int countRepairAreas(List<String> floorPlan)
floorPlan: The condition of the warehouse floor.'X' represents a damaged tile.'.' represents a usable tile.The number of separate repair areas.
1 ≤ floorPlan.size() ≤ 3001 ≤ floorPlan.get(i).length() ≤ 300floorPlan has the same length.floorPlan is either 'X' or '.'. countRepairAreas( floorPlan = List.of(".XX..", ".X...", ".XXX.", "....."))
Returns 1.
All damaged tiles are connected through shared sides, so they form one repair area.
countRepairAreas( floorPlan = List.of("X...X", "XX..X", ".....", "..XX.", "...X."))
Returns 3.
The damaged tiles form separate groups in the upper-left, upper-right, and lower parts of the floor.
countRepairAreas( floorPlan = List.of("X.X", "...", "X.X"))
Returns 4.
None of the four damaged tiles shares a side with another damaged tile.
countRepairAreas( floorPlan = List.of("....", "...."))
Returns 0.
The floor contains no damaged tiles.