3
vector<int> avoidFlood(vector<int> &rains) {4
vector<int> ans(rains.size(), -1);5
unordered_map<int, int> indices; // store the lake and its index6
set<int> st; // stores the indices of zeros8
for (int i = 0; i < rains.size(); ++i) {12
if (indices.find(rains[i]) == end(indices))13
indices[rains[i]] = i;15
int prevDay = indices[rains[i]];16
auto it = st.upper_bound(prevDay);17
if (it == end(st)) return {};19
indices[rains[i]] = i;25
for (int i = 0; i < ans.size(); ++i) {26
if (!rains[i] and ans[i] == -1) ans[i] = 1;