C# - 100% Faster solution using just Dictionary and Linked List
csharp\npublic int[] AvoidFlood(int[] rains)\n{\n\tLinkedList<int> dryDays = new LinkedList<int>();\n\tint[] result = new int[rains.Length];\n\tDictionary<int, 
```csharp\npublic int[] AvoidFlood(int[] rains)\n{\n\tLinkedList<int> dryDays = new LinkedList<int>();\n\tint[] result = new int[rains.Length];\n\tDictionary<int, int> lastRained = new Dictionary<int, int>();\n\n\tfor (int i = 0; i < rains.Length; i++)\n\t{\n\t\tint lake = rains[i];\n\t\tif (lake == 0)\n\t\t{\n\t\t\tdryDays.AddLast(i);\n\t\t\tresult[i] = 1;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// There is already rain on this lake\n\t\t\tif (lastRained.ContainsKey(lake))\n\t\t\t{\n\t\t\t\tint low = lastRained[lake];\n\t\t\t\tint ceiling = -1;\n\n\t\t\t\tforeach (var dryDay in dryDays)\n\t\t\t\t{\n\t\t\t\t\tif (dryDay > low)\n\t\t\t\t\t{\n\t\t\t\t\t\tceiling = dryDay;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (ceiling >= 0)\n\t\t\t\t{\n\t\t\t\t\tresult[ceiling] = lake;\n\t\t\t\t\tdryDays.Remove(ceiling);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\treturn Array.Empty<int>();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlastRained[lake] = i;\n\t\t\tresult[i] = -1;\n\t\t}\n\t}\n\n\treturn result;\n}\n```
[]