very easy code
\n\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& r) {\n        vector<int> ans;\n        int n = r.size();\n\n        // map of lake numbe
\n```\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& r) {\n        vector<int> ans;\n        int n = r.size();\n\n        // map of lake number and day on which it become full on\n        unordered_map<int, int> fulllake;\n\n        // set of available day that can be used for drying a full lake\n        set<int> dryday;\n\n        for (int i = 0; i < n; i++) {\n            if (r[i] == 0) {\n                // if no rain on this day, this is uses to dry any lake later\n                // currently we dont know which lake to be priortize for  drying\n                dryday.insert(i);\n\n                // currently push any number in this index it will later get\n                // updated with lake whom dry by this or if not this updated\n                // than its ok to dry a lake whether it is full or  empty\n                ans.push_back(1);\n            } else {\n                // if rain in this day\n                int lake = r[i];\n\n                // if this lake is already full\n                if(fulllake.find(lake) != fulllake.end()){\n                    // we must dry this lake before it rains in the lake\n                    // so find the day in dryday =>\n                    // that day must be the day that is after the day on which the lake was full\n                    auto it = dryday.lower_bound(fulllake[lake]);\n                    \n                    //if there is no available day then sorry\n                    if(it == dryday.end()){\n                        return {};\n                    }\n\n                    // if find then congrates\n                    int dry  = *it;\n                    ans[dry] = lake; // update lake on that day \n                    dryday.erase(dry);\n                }\n                fulllake[lake] = i; // update that lake bacome full on ith day\n                ans.push_back(-1);\n            }\n        }\n\n        // hurray, successfully avoid flood\n        return ans;\n    }\n};\n```
['Greedy', 'C++']