Clean Python 3, heap and deque O(NlogL)
Time: O(NlogL), where N is the length of rains and L is the most amounts of full lakes in the same time.\nSpace: O(L)\n\nimport collections\nimport heapq\nclass
Time: `O(NlogL)`, where `N` is the length of `rains` and `L` is the most amounts of full lakes in the same time.\nSpace: `O(L)`\n```\nimport collections\nimport heapq\nclass Solution:\n    def avoidFlood(self, rains: List[int]) -> List[int]:\n        full, heap, result = set(), [], []\n        lookup = collections.defaultdict(collections.deque)\n        for i, lake in enumerate(rains):\n            if lake > 0: lookup[lake].append(i)\n        for i, lake in enumerate(rains):\n            if lake > 0:\n                if lake in full: return []\n                result.append(-1)\n                full.add(lake)\n                lookup[lake].popleft()\n                if lookup[lake]:\n                    heapq.heappush(heap, (lookup[lake][0], lake))\n            else:\n                day, urgent_lake = heapq.heappop(heap) if heap else (1, 1)\n                while heap and day <= i:\n                    day, urgent_lake = heapq.heappop(heap)\n                result.append(urgent_lake)\n                full.discard(urgent_lake)\n        return result\n```
[]