[Python] Short, readable, and single pass code! Possibly easiest code to understand
Keep track of dry days, and use a valid dry day for a lake that will be flooded.  What do I mean by valid? A valid day is dry day that happend after the lake wa
Keep track of dry days, and use a **valid** dry day for a lake that will be flooded.  What do I mean by valid? A valid day is dry day that happend after the lake was initially rained on. In other words, you make sure you dry a lake that already has water on it. \n\n```\ndef avoidFlood(self, rains):\n\tfilled, dry_days = {}, []\n\tans = [1] * len(rains)\n\n\tfor day, lake in enumerate(rains):\n\t\tif not lake:\n\t\t\tdry_days.append(day)\n\t\t\tcontinue \n\n\t\tans[day] = -1\n\t\tif lake in filled:\n\t\t\tif not dry_days: return []\n\t\t\t# use the first dry day after the lake was filled (stored in filled[lake])\n\t\t\tdry_on_day_index = bisect.bisect_left(dry_days, filled[lake])\n\t\t\tif dry_on_day_index >= len(dry_days): return []\n\t\t\tdry_on_day = dry_days.pop(dry_on_day_index)\n\t\t\tans[dry_on_day] = lake\n\n\t\tfilled[lake] = day # we fill it on day\n\n\treturn ans\n\n```
[]