โœ๏ธ

Number of Islands

Medium๐Ÿท๏ธ Graphs๐Ÿ“‚ Graphs
๐Ÿงฉ The problem

The grid holds "1" (land) and "0" (water). Count the islands (land connected up/down/left/right).

Examples

  • [["1","1","0"],["0","1","0"],["0","0","1"]] โ†’ 2

๐ŸŽฏ Aim for: O(rows ร— cols) time

โœ๏ธ Write your solution

Pick a language, press Run to try it, then Run tests to check it against every test case โ€” just like a coding interview.

โ† All practice problems