Expand the pond

what are the prerequisites for solving this problem, I have seen the solution for it online but it’s too complex,

@raghav007 it uses dfs on matrix for finding the largest size of connected components with a extra condition of we can mark a cell 1 so that it can also be used in path…
if you have still any confusion let me know…

okay so I will try to put 0 at every location and then try to find the number of ones right and store the max number of ones?

@raghav007 i think it will time limit try some thing else and do it in n*m only

connected component means dsu will be used can you give a hint how?

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

@raghav007 for every dry cell mark all adjacent 4 nodes to which component number they are connected and if there is more than 1 component then try to max the ans lilke connect any two components for example

  • denotes dry cell and number denotes the component number

1 + 2
1 + 2
1 1 +

for + in first row we can attach components 1 and 2 so max the ans
like ans=max(ans,sizeof(1),sizeof(2)) and if more than 2 components attached then also maximize for it…