← Questions
Sizes of connected regions in a binary image, in scan order
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A binary image is an m x n grid of 0s and 1s. Foreground pixels (1s) that touch up, down, left or right belong to the same region; diagonal neighbours do not. Return the size of every region, listed in the order you first meet a pixel of that region when scanning the image row by row, left to right. Discuss BFS versus DFS, recursion depth on large images, and the time and space cost.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
