Find Connected Foreground Regions

Given a rectangular binary matrix image:

  • 1 represents a foreground pixel.
  • 0 represents a background pixel.
  • Two foreground pixels belong to the same region only if they are horizontally or...

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: