[Python]  Heap solution with detail explaination
This problem seems pretty complex, however when we divide them into small cases it will become much clearer.\n\n- When raining\n    - Need to check if there is 
This problem seems pretty complex, however when we divide them into small cases it will become much clearer.\n\n- When raining\n    - Need to check if there is flood, so we need a `full` set to store all full lakes.\n    - The `ans` must append with -1.\n- When not raining\n    - Now we can dry full lake. How? \n    - We have to need a `dry` to store the dry plan for lakes. How to make the dry plan?\n    - It\'s actually a greedy algorithm: **dry the full lake with earliest next rain first**. Thus the `dry` should be a\n     `Heap` so that the first one is always the earliest.\n    - If we don\'t have a dry plan, then `ans` can append whatever.\n    \nBack to the first, we need an extra `lakes`(`dict[deque]`) to store the rain order for each lake. When it rains to a\n lake, we need to check if there\'s next rain for it, so that store the next rain date(index) to `dry`.\n\n```\nclass Solution:\n    def avoidFlood(self, rains: List[int]) -> List[int]:\n        \n        ans = []\n        # full stores current full lakes\n        full = set()\n        # dry stores dry plan for full lakes, the first is the earliest upcomming rain\n        dry = []\n        # for each lake, stores rain deque for it\n        lakes = collections.defaultdict(collections.deque)       \n        for i, lake in enumerate(rains):\n            lakes[lake].append(i)\n        \n        for lake in rains:\n            if lake:\n                # If lake is already full, then it will be a flood\n                if lake in full: return []\n                else:\n                    full.add(lake)\n                    ans.append(-1)\n                    lakes[lake].popleft()\n                    # If there are more rains for this lake later, store the next rains idx into dry\n                    # dry is Heap so that the first one is always the smallest idx (earlist rain)\n                    if lakes[lake]:\n                        heapq.heappush(dry, lakes[lake][0])\n            else:\n                if dry: \n                    next_dry = rains[heapq.heappop(dry)]\n                    ans.append(next_dry)\n                    full.remove(next_dry)\n                else:\n                    ans.append(1)\n                    \n        return ans\n```
['Greedy', 'Heap (Priority Queue)', 'Python']