Here is the step-by-step approach:
Loop through every cell in the grid.
If you find a land cell () that has not been visited, trigger DFS from that cell.
DFS marks the cell as visited (set to ), then recursively calls DFS on all neighbors. Each recursive call returns the area of that branch.
DFS returns (current cell) plus the sum of areas from all neighbors.
Track the maximum area returned by any DFS call.
Return the maximum after visiting all cells.
The recursion builds the area bottom-up, starting from leaf cells and accumulating as it returns.