Number of Islands II

  • 0

    Click here to see the full article post

  • 0

    Create parent[mn+1] and reserve parent[0] to indicate whether a cell is water.
    Since the init value of new int[m * n + 1] is 0, you can avoid the array initialization of complexity O(mn).
    you can achieve O(klog(mn)).

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.