Algorithms Playbook
← All problems
MediumBFS & DFS →Similar to: Number of Islands

How many islands?

Problem

Given a grid of '1' (land) and '0' (water), return the number of islands. An island is a group of land cells connected horizontally or vertically.

Examples

Input: ["11000","11000","00100","00011"]

Output: 3

Hints

    Try it first. Every hint reveals a bit more.

    Solution