You are given an integer array rains representing a weather forecast across several days, where each lake is initially dry.
On day i:
If rains[i] > 0, it rains over lake rains[i]. If lake rains[i] is already full, a flood occurs.
If rains[i] == 0, no rain occurs, and you may choose one lake to drain completely.
Return an array ans of the same length as rains such that:
ans[i] == rains[i] > 0.
ans[i] is the number of the lake chosen to be drained if rains[i] == 0. If no lake needs to be drained, any valid lake number greater than
If it is impossible to avoid a flood, return an empty array. If multiple valid configurations exist, return any of them.
Constraints:
rains.length
rains[i]
You are given an integer array rains representing a weather forecast across several days, where each lake is initially dry.
On day i:
If rains[i] > 0, it rains over lake rains[i]. If lake rains[i] is already full, a flood occurs.
If rains[i] == 0, no rain occurs, and you may choose one lake to drain completely.
Return an array ans of the same length as rains such that:
ans[i] == rains[i] > 0.
ans[i] is the number of the lake chosen to be drained if rains[i] == 0. If no lake needs to be drained, any valid lake number greater than
If it is impossible to avoid a flood, return an empty array. If multiple valid configurations exist, return any of them.
Constraints:
rains.length
rains[i]