C++ Solution use 2 maps to solve the problem
Use 2 maps: nextDayHappen & lastDayHappen\n\n\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& rains) {\n        map<int, int> nextDayHappen;
Use 2 maps: nextDayHappen & lastDayHappen\n\n```\nclass Solution {\npublic:\n    vector<int> avoidFlood(vector<int>& rains) {\n        map<int, int> nextDayHappen;\n        map<int, int> lastDayHappen;\n        for(int i = 0; i < rains.size(); i++){\n            if(rains[i] > 0){\n                if(lastDayHappen[rains[i]]){\n                    nextDayHappen[lastDayHappen[rains[i]]] = i + 1;\n                }\n                lastDayHappen[rains[i]] = i + 1; // The day number begins from 1.    \n            }\n        }\n        priority_queue<int, vector<int>, greater<int> > emergencyQue;\n        map<int, int> currWater;\n        vector<int> res;\n        for(int i = 0; i < rains.size(); i++){\n            if(rains[i] > 0){\n                if(currWater[rains[i]]){\n                    // we fail\n                    return vector<int>();\n                }\n                currWater[rains[i]]++;\n                res.push_back(-1);\n                if(nextDayHappen[i + 1])\n                    emergencyQue.push(nextDayHappen[i + 1]);\n            }else{\n                if(emergencyQue.size()){\n                    res.push_back(rains[emergencyQue.top() - 1]);\n                    currWater[rains[emergencyQue.top() - 1]] = 0;\n                    emergencyQue.pop();\n                }else{\n                    res.push_back(1);\n                }\n            }\n        }\n        return res;\n    }\n};\n```
[]