#K33257. Maximum Region Area
Maximum Region Area
Maximum Region Area
You are given a grid of integers with n rows and m columns. Each cell in the grid represents an elevation. A region is defined as a group of adjacent cells (neighbors up, down, left, or right) that have the same value. Your task is to compute the maximum region area in the grid.
Formally, if we define the area of a region as \( A = \text{number of cells in the region} \), you are required to find the maximum \( A \) over all regions in the grid.
Note: Adjacency is considered only in the four cardinal directions (up, down, left, right).
inputFormat
The first line of input contains two integers, n and m, separated by a space, where n is the number of rows and m is the number of columns.
Each of the next n lines contains m space-separated integers representing the grid values.
Example:
4 4 1 1 2 2 1 1 2 2 3 3 4 4 3 3 4 4
outputFormat
Output a single integer representing the maximum area of any region in the grid.
Example:
4## sample
4 4
1 1 2 2
1 1 2 2
3 3 4 4
3 3 4 4
4