Skip to main content
Number of Islands | AlgoCracked
AlgoCracked
ProblemsNumber of Islands
Medium58.0% acceptance
Blind75ArrayDfsBfsUnion Find

Number of Islands

Given a grid of 1 (land) and 0 (water) characters, return the number of islands . An island is a group of land cells connected horizontally or vertically; the whole grid is surrounded by water. Input format Input is [grid] where grid is a 2-D array of single-character strings, e.g. [[[ 1 , 1 , 0 ],[ 0 , 1 , 0 ],[ 0 , 0 , 1 ]]] .

Loading workspace…