It's a variation of the famous problem of Number of Islands. I want to know the algorithm thinking approach(hint). If I want to connect all the islands given that island can be connected in all 8 directions not in 4 directions. Then how should I approach this problem?
Example
Given Matrix is[[1 1 0 0 0][0 1 0 0 1][1 0 0 1 1][0 0 0 0 0][1 0 1 0 1]
Output for this will be 2
