17 lines
244 B
Python
17 lines
244 B
Python
from itertools import product
|
|
|
|
grid = [
|
|
["1","1","1","1","0"],
|
|
["1","1","0","1","0"],
|
|
["1","1","0","0","1"],
|
|
["0","0","0","1","0"]
|
|
]
|
|
|
|
def numIslands(grid):
|
|
|
|
|
|
def dfs(i, j):
|
|
|
|
if i<0 and
|
|
|
|
print( numIslands(grid) ) |