******************practice

how can we do this ques?
/A state is divided into RC cities.The government has launched an initiative
to find the cities which are dominated by coders. Each city may or may not
have coders residing in it. If the city is dominated by coders, it is marked
with 1 else it is marked with 0. Two cities are termed as connected cities if
they both are dominated by coders and can be reached by moving vertically,
horizontally, or diagonally.
input: [1,1,1,0
0,1,1,0,
0,0,0,1
1,1,0,1
1,0,0,1]
output: 5
*/

hello @nmaurya760

how output is 5 ?

Uploading: IMG20201007011037.jpg…

@nmaurya760
if it is asking for the maximum count of number of coders in connected city.
then it is very easy task .

initilaly mark all 1’s as unvisited and then run a dfs from each unvisited 1 to find number of coders in connected city compare it with ur previous answer and updated if number of coders is more in current connected city and mark all connected one as visited.

repeat this process for all unvisited 1 and then print ur answer

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.