graph algorithm - Minimum number of changes that we need to make so that there will be only one island in matrix -
a matrix containing 0s , 1s provided, 0s water , 1s land. group of connected 1s forms island. if 1 change can convert 1 0 1 find out minimum number of changes need make there 1 island in matrix.
for example:
matrix->
1 0 1 0 0 0 1 0 1
minimum number of changes convert single island 1. convert (2,2) 1.
i asked question in interview. used dfs find out number of islands. can't approach solve further.
Comments
Post a Comment