← Questions
Biggest connected component after filling one row or column
0
I was asked this
No reports yet. Sign in to say where you were asked it.
You get an h by w grid of 0s and 1s. Cells holding 1 are connected when they touch up, down, left or right. You may pick one whole row or one whole column and set every cell in it to 1, or do nothing. Return the size of the largest connected group of 1s you can end up with.
The grid can hold close to a million cells, so trying every row and column with a fresh flood fill is too slow: label the existing components once, then work out how much each row or column would join together.
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
