Efficient connected components from a 2D array
In an m x n
matrix consisting of 0
s and 1
s, we are tasked with counting the 4-directionally connected islands of 1
s. A python implementation is as follows:
In an m x n
matrix consisting of 0
s and 1
s, we are tasked with counting the 4-directionally connected islands of 1
s. A python implementation is as follows: