I need help with logic after normal count of connected components on the matrix?

i realise that i need to find the size of every connected component in the matrix but how to i ensure the max area?

hello @shibangi

go to each cell and then see what is maximum cells u can visit from here.
and keep the track of maximum .

at the end print the maximum.

to find maximum cell u can visit from (i,j) use disjoint set

check this->