package main
/**
* 判断岛屿数量
* @param grid char字符型二维数组
* @return int整型
*/
func solve( grid [][]byte ) int {
sum := 0
for i:=0;i<len(grid);i++{
for j:=0;j<len(grid[i]);j++{
if grid[i][j] == '1'{
sum++
markIsland(grid,i,j)
}
}
}
return sum
}
func markIsland(grid [][]byte, row, col int) {
if row >= 0 && row < len(grid) && col >= 0 && col < len(grid[row]) && grid[row][col] == '1'{
grid[row][col] = '2'
markIsland(grid,row-1,col)
markIsland(grid,row+1,col)
markIsland(grid,row,col-1)
markIsland(grid,row,col+1)
}
}