#C922. Find the Largest Island
Find the Largest Island
Find the Largest Island
You are given a grid of size (n \times m) where each cell is either 'L' (land) or 'W' (water). An island is defined as a group of connected 'L' cells connected horizontally or vertically. Your task is to determine the size of the largest island in the grid. If there is no island, output 0.
For example, consider the following grid:
LLLLW LLLLW WWWWW LLLWW
The largest island in this grid has 8 cells.
inputFormat
The first line of input contains two integers (n) and (m), representing the number of rows and columns respectively. The next (n) lines each contain a string of length (m) consisting of only the characters 'L' and 'W'.
outputFormat
Output a single integer that represents the size of the largest island in the grid.## sample
4 5
LLLLW
LLLLW
WWWWW
LLLWW
8
</p>