Python 93.75 %
Using bisect_right\n\nclass Solution(object):\n    def avoidFlood(self, rains):\n        """\n        :type rains: List[int]\n        :rtype: List[int]\n       
Using bisect_right\n```\nclass Solution(object):\n    def avoidFlood(self, rains):\n        """\n        :type rains: List[int]\n        :rtype: List[int]\n        """\n        q=[] # list for zeros positions\n        ans=[]\n        hashmap={}\n        for i in range(len(rains)):\n            if rains[i] == 0:\n                q.append(i)\n                ans.append(1)  # as per example 4\n            else:\n                if rains[i] in hashmap:    \n                    if len(q) == 0:\n                        ans=[]\n                        break\n                    else:\n                        index = hashmap[rains[i]]\n                        # find a zero position just greater than previous occurrence of rains[i]\n                        pos=bisect.bisect_right(q, index) \n                        if pos<len(q): # no zero exists in between occurrence\n                            ans[q[pos]]=rains[i]\n                            q.pop(pos)\n                        else:\n                            ans=[]\n                            break\n                hashmap[rains[i]]=i\n                ans.append(-1)  \n            \n        return ans\n```
[]