Set and Binary Search soln. C++
The main idea is to store the lakes with their latest date of rain in a map and store the dry dates in a set. \nWhenever you get a lake which is already filled 
The main idea is to store the lakes with their latest date of rain in a map and store the dry dates in a set. \nWhenever you get a lake which is already filled check if there is dry date just after the lakes\' previous rain date so that you can dry that date if not you can return empty list cause you cannot stop the flood. If you get such a date update the answer with that lake no.\nCode is self explanatory.\n\n```\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& rains) {\n        unordered_map<int,int> mp;\n        int n = rains.size();\n        vector<int> ans;\n        set<int> st;\n        \n        for(int i = 0 ; i < n ; i++) {\n            \n            if(rains[i] == 0) {\n                st.insert(i);\n                ans.push_back(1);\n            }\n            else \n            {\n                if(mp.find(rains[i]) != mp.end()) {\n                int x = rains[i];\n                auto it = st.lower_bound(mp[x]);\n                \n                //cout<<x<<" "<<*it<<" ";\n                    \n                if(it == st.end())\n                    return {};\n                \n                ans[*it] = rains[i];\n                st.erase(*it);\n            }\n                mp[rains[i]] = i;\n                ans.push_back(-1);\n        }\n    }   \n        return ans;\n    }\n};\n```\n
['C', 'Binary Tree', 'Ordered Set']