class Solution: def minimumEffortPath(self, heights): m, n = len(heights), len(heights[0]) neibs = [[1, 0], [0, 1], [-1, 0], [0, -1]] def dfs(LIMIT, x, y): visited.add((x, y)) for dx, dy in neibs: if 0<=dx+x