C++ solution sets & hashmap
You can\'t empty a lake before it is filled (obvious)\n\n#define Vi vector<int>\n#define ub upper_bound\nclass Solution {\npublic:\n    vector<int> avoidFlood(v
**You can\'t empty a lake before it is filled (obvious)**\n```\n#define Vi vector<int>\n#define ub upper_bound\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& rains) {\n        unordered_map<int,int>mp;\n        set<int>zero;\n        int n= rains.size();\n        Vi ans(n,-1);\n        for(int i=0;i<n;i++){\n            if(rains[i]==0){\n                zero.insert(i);\n                ans[i]=1;\n                continue;\n            }\n            if(mp.count(rains[i])){\n                auto key=zero.ub(mp[rains[i]]);\n                if(key==zero.end()){\n                    return {};\n                }\n                ans[*key]=rains[i];\n                zero.erase(key);\n            }\n            mp[rains[i]]=i;\n        }\n    return ans;\n    }\n};\n```
['Hash Table', 'Ordered Set']