Your country has an infinite number of lakes. Initially, all the lakes are empty, but when it rains over the nth lake, that lake becomes full of water. If it rains over a lake that is full of water, there will be a flood.
Your goal is to avoid floods in any lake.
Given an integer array rains where:
rains[i] > 0 means it will rain over lake rains[i].rains[i] == 0 means there is no rain this day, and you must choose one lake to dry.Return an array ans where:
ans.length == rains.lengthans[i] == -1 if rains[i] > 0.ans[i] is the lake you choose to dry on the ith day if rains[i] == 0.If there are multiple valid answers, return any of them. If it is impossible to avoid a flood, return an empty array.
Note: If you choose to dry a full lake, it becomes empty. If you dry an empty lake, nothing changes.
1 <= rains.length <= 10^50 <= rains[i] <= 10^9rains = [1,2,3,4][-1,-1,-1,-1]rains = [1,2,0,0,2,1][-1,-1,2,1,-1,-1]rains = [1,2,0,1,2][]