Question bank › Graphs Bfs
Dsa Graphs Bfs Easy

Island Map Area Counting

You are provided with a grid that represents a map of islands where '1' represents land and '0' represents water. Your task is to find the number of islands on the map. Two pieces of land are part of the same island if they are horizontally or vertically connected. Count the number of distinct islands in the grid. Input: The first line contains two integers n and m (1 <= n, m <= 100), the dimensions of the grid. The following n lines contain m characters ('0' or '1'). Output: An integer representing the number of islands on the map. Example: Input: 4 5 1 0 0 1 0 0 0 1 0 1 1 0 0 0 0 0 1 1 0 0 Output: 5

Key concepts

graphsbfsconnected components

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