Question bank › Graphs Dfs
Dsa Graphs Dfs Easy

Island Size Calculator

You are given a 2D grid representing a map of '1's (land) and '0's (water). Write a function to compute the size of the largest island (connected '1's vertically or horizontally) in the grid. Input: First line contains two integers, m (rows) and n (columns) (1 <= m, n <= 100). The next m lines contain n integers each (0 or 1). Output: Print the size of the largest island. Example: Input: 4 5 1 0 0 1 0 1 1 0 0 0 0 0 1 0 1 0 1 1 0 0 Output: 5

Key concepts

graphsdfsgrid

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.