Question bank › Graphs Bfs
Dsa Graphs Bfs Medium

Island Discovery

You are given a grid representing a map of islands (1) and water (0). You need to count the number of separate islands in the grid. An island is defined as a group of adjacent 1's connected vertically or horizontally. The task is to identify how many islands are present. Input: - The first line contains two integers, R (rows) and C (columns) of the grid. - The next R lines contain C integers (0 or 1). Output: - An integer representing the number of separate islands found in the grid. Example: Input: 4 5 1 1 0 0 0 0 1 0 1 1 0 0 0 1 0 1 0 0 0 1 Output: 4

Key concepts

graphsbfsislanddiscovery

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.