Skip to Content

Longest corridor

Level A. Teaches grids, [Row, Col]Char and per-row state.

A floor plan is a grid of h rows and w columns (1 ≤ h, w ≤ 50). Each cell is . (floor) or # (wall). A corridor is a run of consecutive floor cells in one row. Print the length of the longest corridor, or 0 if there is no floor.

Input: h and w, then h lines of w characters. Output: one integer.

InputOutput
3 4
..#.
.##.
....
4
9 tests · Ctrl+Enter