Runtime 89, memory 100
\n\nclass Solution:\n    def avoidFlood(self, rains: List[int]) -> List[int]:\n        full = {}\n        ans = [-1]*len(rains)\n        zeros = []\n        \n 
\n```\nclass Solution:\n    def avoidFlood(self, rains: List[int]) -> List[int]:\n        full = {}\n        ans = [-1]*len(rains)\n        zeros = []\n        \n        for index, rain in enumerate(rains):\n            p = 0\n            if rain == 0 :\n                zeros.append(index)\n                continue\n            if rain not in full :\n                full[rain] = index\n            else:\n                if len(zeros) == 0:\n                    return []\n                else:\n                    for x in zeros:\n                        if x > full[rain] and x < index:\n                            ans[x] = rain\n                            zeros.remove(x)\n                            full[rain] = index\n                            p = 1\n                            break\n                    if p == 0:\n                        return []\n                        \n        for x in zeros:\n            ans[x] = 1\n        return ans\n```
[]