package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
200. Number of Islands
Solution idea
DFS
BFS
Union Find
思路总结
- 遍历每一个节点,如果节点=1,看它上下左右四个方向的邻居是否=1,如果是,就Union起来
- 技巧: 1-D index compression
Time Complexity = O(rows*cols)