Python BFS flip water and land and then start with water
py\n\'\'\'\nw: BFS\nh: first we flip the 0 and 1 to be 1 and 0 and append water cell to queue\n\tthen we start from water cell, do the regular BFS for all the w
```py\n\'\'\'\nw: BFS\nh: first we flip the 0 and 1 to be 1 and 0 and append water cell to queue\n\tthen we start from water cell, do the regular BFS for all the water cells\n\'\'\'\nimport collections\nclass Solution:\n    def highestPeak(self, isWater: List[List[int]]) -> List[List[int]]:\n        m = len(isWater)\n        n = len(isWater[0])\n        \n        direction = [(0,1),(0,-1),(1,0),(-1,0)]\n\t\t\n        queue = collections.deque([])\n        seen = set()\n        for i in range(m):\n            for j in range(n):\n                if isWater[i][j] == 1:\n                    isWater[i][j] = 0\n                    queue.append((i, j))\n                    seen.add((i,j))\n                else:\n                    isWater[i][j] = 1\n                    \n        while queue:\n            x, y = queue.popleft()\n            for dx, dy in direction:\n                nx = x + dx\n                ny = y + dy\n                if 0 <= nx < m and 0 <=ny<n and (nx,ny) not in seen and isWater[nx][ny]:\n                    isWater[nx][ny] = isWater[x][y] + 1\n                    queue.append((nx,ny))\n                    seen.add((nx,ny))\n        \n        #print(isWater)\n        return isWater\n```
['Breadth-First Search', 'Python']