C++  Clean and readable code with comments
\n vector<int> avoidFlood(vector<int>& rains) {\n        int n=rains.size();\n        vector<int>result(n,-1);\n        // it will keep track of already filled 
```\n vector<int> avoidFlood(vector<int>& rains) {\n        int n=rains.size();\n        vector<int>result(n,-1);\n        // it will keep track of already filled lakes\n        unordered_map<int,int>mymap;\n        \n        //it will keep the track of available dry day\n        map<int,int>dry_day;\n        \n        for(int i=0;i<n;i++){\n             if(rains[i]==0){\n                 dry_day[i]++;\n                 continue;\n             }\n           //else  if rains[i] lake is already visited\n            if(mymap.find(rains[i])!=mymap.end()){\n                    //now we will check available dry day after the rains[i] lake was filled\n                   int last_date=mymap[rains[i]];\n                   auto it=dry_day.upper_bound(last_date);\n                   if(it!=dry_day.end()){\n                        //it meanse some dry days is available after last_date\n                        //now,we will make rains[i] lake  empty\n                         mymap.erase(rains[i]);\n\t\t\t\t\t\t \n                        //pushing it in result array\n                         result[it->first]=rains[i];\n\t\t\t\t\t\t \n                         //removing the filled dry day from aur map\n                          dry_day.erase(it);\n                   }\n                  else{\n                    //it meanse there was no available dry day after last_date for rains[i] lake\n                     return{};\n                    }\n                \n                \n            }\n            mymap[rains[i]]=i;\n             \n        }\n\t\t// we can empty any lake  if we have more dry day than required\n        while(dry_day.size()){\n            auto it=dry_day.begin();\n            result[it->first]=1000000;\n            dry_day.erase(it);\n        }\n        return result;\n        \n        \n        \n    }\n```
[]