Schedule Dry Days to Prevent Any Lake Flood. Lakes1..1000000000 start empty. A positive rains[i] fills that lake; rain on an already full lake causes a flood.
### Problem
Lakes 1..1000000000 start empty. A positive rains[i] fills that lake; rain on an already full lake causes a flood. On a zero day,you must choose one lake to dry; drying an empty lake is allowed. Return a same-length plan with -1 on rainy days and the chosen lake number on dry days. Any flood-free plan is accepted; return an empty array if none exists.
```cpp
class Solution {
public:
vector<int> avoidFlood(vector<int>& rains);
};
```
### Examples
**Example 1:**
```text
Input: rains = [3,0,3]
Output: [-1,3,-1]
Explanation: Dry lake3 between its two rains.
```
**Example 2:**
```text
Input: rains = [4,4]
Output: []
Explanation: The second consecutive rain floods lake4,and no dry day is available.
```
### Constraints
- rains has length 1 to 100000.
- `0 <= rains[i] <= 1000000000`; positive values identify lakes,and 0 identifies a dry day.
### Contract considerations
The returned lake choices are genuinely non-unique; for rains[0],drying lake 1 or lake 2 are both valid.
```hint Read the boundary condition
Check repeated rain on one lake and the timing of each assigned dry day. Unused drying capacity may name an empty lake, and different valid plans remain acceptable.
```
### What a Strong Answer Covers
The returned lake choices are genuinely non-unique; for rains[0],drying lake 1 or lake 2 are both valid.
### Follow-up Questions
Optional practice extension,separate from the original task: How would a limit on which lakes each dry day may drain change the scheduling problem?
Overview: Schedule Dry Days to Prevent Any Lake Flood. Lakes1..1000000000 start empty. A positive rains[i] fills that lake; rain on an already full lake causes a flood.
Lakes 1..1000000000 start empty. A positive rains[i] fills that lake; rain on an already full lake causes a flood. On a zero day,you must choose one lake to dry; drying an empty lake is allowed. Return a same-length plan with -1 on rainy days and the chosen lake number on dry days. Any flood-free plan is accepted; return an empty array if none exists.
class Solution {
public:
vector<int> avoidFlood(vector<int>& rains);
};
Examples
Example 1:
Input: rains = [3,0,3]
Output: [-1,3,-1]
Explanation: Dry lake3 between its two rains.
Example 2:
Input: rains = [4,4]
Output: []
Explanation: The second consecutive rain floods lake4,and no dry day is available.