ByteByteGo logo
menuProblems List

Count Islands

Medium

Given a binary matrix representing 1s as land and 0s as water, return the number of islands.

An island is formed by connecting adjacent lands 4-directionally (up, down, left, and right).

Example:

Output: 2

You can practice coding exercises online by logging into bytebytego.com on your laptop.