[Python] Solution with bisect
Here is my Python solution. I know that it is O(N^2) because of the last dry.pop(idx) but it is fast enough to pass the LC tests.\n\nclass Solution:\n    def av
Here is my Python solution. I know that it is O(N^2) because of the last ```dry.pop(idx)``` but it is fast enough to pass the LC tests.\n```\nclass Solution:\n    def avoidFlood(self, rains: List[int]) -> List[int]:\n        full = dict() # store the last day a lake was filled with water\n        i = 0\n        dry = [] # array with dry days where we will search when needed\n        res = [-1 for _ in range(len(rains))]\n        for i in range(len(rains)):\n            if rains[i] == 0:\n                dry.append(i)\n                continue\n            if not rains[i] in full:\n                full[rains[i]] = i\n                continue\n            # search a dry day after the last day the lake was filled with water\n            idx = bisect_right(dry, full[rains[i]])\n            if idx == len(dry):\n                # we didn\'t find a good day\n                return []\n            res[dry[idx]] = rains[i]\n            full[rains[i]] = i\n            dry.pop(idx)\n        for x in dry:\n            res[x] = 1\n        return res\n```
[]