Question Given an m x n 2D binary grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
grid = [["1","1","0"],["0","1","0"],["0","0","1"]] → 3
Code
select rect note arrow text clear
Number of Islands m × n binary grid 1 1 0 0 1 0 0 0 1 1 = land 0 = water 4-neighbors
Play Pause Stop
Loading free system voices…
Loading free system voices…
Visual Session
Voice Camera Screen Camera + Screen Interactive Coding Presentation
Start a visual session — camera and screen are off until you choose a mode above.
🎤 Mic ⏺ Record
Camera and screen are only active with your permission. Frames are sampled periodically — not sent continuously.
Stopped — press Play to start
🎙 Done
Finish