I first used a "visited" set to store visited point, and then I found my old implementation set the visited point to "2", as posted. Then I was confused, isn't string immutable?

Problem solved: input are not list of strings.

```
def numIslands(self, grid):
# BFS
if not grid:
return 0
m, n, count = len(grid), len(grid[0]), 0
for i in range(m):
for j in range(n):
if grid[i][j] == "1":
count += 1
stack = [(i,j)]
for ii,jj in stack:
if 0<=ii<m and 0<=jj<n and grid[ii][jj] == "1":
grid[ii][jj] = "2"
stack.extend([(ii+1,jj),(ii-1,jj),(ii,jj-1),(ii,jj+1)])
return count
# DFS
if not grid:
return 0
m, n, count = len(grid), len(grid[0]), 0
for i in range(m):
for j in range(n):
if grid[i][j] == "1":
count += 1
stack = [(i,j)]
while stack:
ii, jj = stack.pop()
if 0<=ii<m and 0<=jj<n and grid[ii][jj] == "1":
grid[ii][jj] = "2"
stack.extend([(ii+1,jj),(ii-1,jj),(ii,jj-1),(ii,jj+1)])
return count
## recursive DFS
def dfs(grid, i,j):
if 0<=i<m and 0<=j<n and grid[i][j] == "1":
grid[i][j] = "2"
dfs(grid, i-1, j)
dfs(grid, i+1, j)
dfs(grid, i, j-1)
dfs(grid, i, j+1)
if not grid:
return 0
m, n, count = len(grid), len(grid[0]), 0
for i in range(m):
for j in range(n):
if grid[i][j] == "1":
count += 1
dfs(grid, i, j)
return count
```