#C10435. Largest Island Size
Largest Island Size
Largest Island Size
Given a grid of size \( n \times m \) where each cell contains either \(0\) (representing water) or \(1\) (representing land), determine the size of the largest island. An island is defined as a group of adjacent land cells (connected horizontally or vertically).
Input: The first line contains two integers \(n\) and \(m\). Each of the next \(n\) lines contains \(m\) space-separated integers (either 0 or 1) representing the grid.
Output: Output a single integer representing the size of the largest island in the grid.
Example:
Input: 4 5 1 1 0 0 0 1 1 0 1 1 0 0 0 0 1 0 0 0 1 1</p>Output: 5
inputFormat
The first line contains two integers \(n\) and \(m\) (number of rows and columns respectively). The following \(n\) lines each contain \(m\) integers, where each integer is either \(0\) (water) or \(1\) (land).
outputFormat
Output a single integer which is the size of the largest island found in the given grid.
## sample4 5
1 1 0 0 0
1 1 0 1 1
0 0 0 0 1
0 0 0 1 1
5