Recursion in DFS class Solution: def countPaths(self, grid: List[List[int]]) -> int: if not grid: return 0