Expand the pond doubt

hint please , or explanation for few more test cases

Hello @rohit_1906,

let say, input is :-
0 0 1 1
0 0 0 0
0 1 1 1

here if we convert the 0 at (1,2) into 1 then it will look like:-
0 0 1 1
0 1 0 0
0 1 1 1
so the maximum size will be 4.

if convert (1,3) into 1, then
0 0 1 1
0 0 1 0
0 1 1 1
here the largest size will be 6.

similarly, convert (1,4)
0 0 1 1
0 0 0 1
0 1 1 1
here again the largest size will be 6.

So 6 is our answer.

Tip:- Use DFS for all the connected components and also store size of each component.

Hope, this would help.