Dsa
Graphs Bfs
Easy
Island Size Calculation
Given a grid of land and water cells, find the size of the largest island in the grid. You represent water with '.' and land with '#'. An island is formed by connecting adjacent land cells horizontally or vertically. Write a function that returns the size of the largest island. Input:
A grid of size N x M consisting of characters '.' and '#'.
Output:
An integer representing the size of the largest island.
Example:
Input:
4 5
.....
..#..
..#..
.....
Output:
2
Key concepts
graphsbfsexploration
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now