Skip to content

Instantly share code, notes, and snippets.

@acibiber53
acibiber53 / number_of_islands_dfs.py
Last active August 13, 2020 16:17
Number of Islands question recursive DFS solution
class Solution:
def numIslands(self, grid):
# They have empty input
if not grid:
return 0
directions = {"up": (-1,0), "down":(1,0), "left":(0,-1), "right":(0,1)}
island_number = 0
lenx, leny = len(grid), len(grid[0])
def land_zeroizer(x, y):