Avoid Flood in The City nlon(n) solution
```\nvector avoidFlood(vector& rains) {\n        set day;\n        map m;\n        int n=rains.size();\n        day.insert(n);\n        vector ans(n,0);\n      
```\nvector<int> avoidFlood(vector<int>& rains) {\n        set<int> day;\n        map<int,int> m;\n        int n=rains.size();\n        day.insert(n);\n        vector<int> ans(n,0);\n        for(int i=0;i<n;i++){\n            if(rains[i]!=0){\n                if(m.find(rains[i])!=m.end()){\n                   int t=*(day.upper_bound(m[rains[i]]));\n                    if(t<n){\n                        day.erase(t);\n                        m[rains[i]]=i;\n                        ans[t]=rains[i];\n                        ans[i]=-1;\n                    }\n                    else{\n                        return {};\n                    }\n                }\n                else{\n                    m[rains[i]]=i;\n                    ans[i]=-1;\n                }\n            }\n            else{\n                day.insert(i);\n            }\n        }\n        for(int i=0;i<ans.size();i++){\n            if(ans[i]==0){\n                ans[i]=1;\n            }\n        }\n        return ans;\n    }\n
['Binary Tree', 'Ordered Set', 'C++']