Number of Islands (Union-Find)

Medium

📝 Description

Count number of islands in 2D grid using Union-Find

Input Format

[[0 or 1, ...], ...] (2D grid)

Output Format

integer

Constraints

m,n ≤ 300

🔍 Sample Input

[["1","1","0","0","0"],["1","1","0","0","0"],["0","0","1","0","0"],["0","0","0","1","1"]]
            

✅ Sample Output

3
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run