Hi, I'm trying to solve this problem: Islands
I know this problem it can be solve with union find, but i don't know how use it. Because I'm doing a walk-through per year and for each year I do a walk-through per node, for that the complexity it would be quadratic.
I have thought to do it linear(O(nlogn)), flood all the island fully and then start decreasing the water level. But I don't know how to do it the walk-through for the array.