Practice Avoid Flood in The City
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Avoid Flood in The City
Problem Statement
All 10^9 lakes start empty. On day i, a positive rains[i] fills that lake; filling an already full lake causes a flood. When rains[i] = 0, choose one lake to empty, including an already empty lake if desired. Return one entry per day: -1 on rainy days and the chosen lake number on dry days. Any flood-free schedule is valid; return [] if none exists.
Source: Avoid Flood in The City on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
rains = [1,2,3,4]
[-1,-1,-1,-1]
# Example 2
rains = [1,2,0,0,2,1]
[-1,-1,2,1,-1,-1]
# Example 3
rains = [1,2,0,1,2]
[]
Constraints
Related LeetCode Problems
Practice more problems similar to Avoid Flood in The City.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.