Skip to content

Commit

Permalink
update codes and links
Browse files Browse the repository at this point in the history
  • Loading branch information
EndlessCheng committed Apr 18, 2020
1 parent a39d449 commit ea0c428
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions copypasta/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package copypasta

import "sort"

// NOTE: 对于搜索格子的题,可以不用创建 vis 而是通过修改格子的值为范围外的值(如零、负数、'#' 等)来做到这一点
func searchCollection() {
// DFS 格点找有多少个连通分量
// 下列代码来自 LC162C https://leetcode-cn.com/problems/number-of-closed-islands/
// NOTE: 对于搜索格子的题,可以不用创建 vis 而是通过修改格子的值为范围外的值(如零、负数、'#' 等)来做到这一点
dfsGrids := func(grid [][]int) (comps int) {
dir4 := [...][2]int{{-1, 0}, {1, 0}, {0, -1}, {0, 1}} // 上下左右
n, m := len(grid), len(grid[0])
Expand All @@ -19,7 +19,7 @@ func searchCollection() {
if i < 0 || i >= n || j < 0 || j >= m {
return false
}
if vis[i][j] || grid[i][j] == 1 {
if vis[i][j] || grid[i][j] != 0 {
return true
}
vis[i][j] = true
Expand Down

0 comments on commit ea0c428

Please sign in to comment.