C++ | Clean code |Set and unordered_map
\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& rains) {\n     vector<int>ans;\n     unordered_map<int,int>mp;\n     int size=rains.size();
```\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& rains) {\n     vector<int>ans;\n     unordered_map<int,int>mp;\n     int size=rains.size();\n       set<int>st; \n      for(int i=0;i<size;i++){\n          if(rains[i]==0){\n            st.insert(i);\n              ans.push_back(1);\n          }\n          else{\n              if(mp.find(rains[i])!=mp.end()){\n                  auto it=st.lower_bound(mp[rains[i]]);\n                  if(it==st.end())\n                      return {};\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```\nDo **UPVOTE** if it helps:)
['C']