Return the Sizes of All Islands

Given a binary matrix grid containing only 0s and 1s:

  • 0 represents water;
  • 1 represents land;
  • An island is formed by land cells connected vertically or horizontally. Diagonal connectio...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: