Is there a solution that is better than O(n^2)?
Anonymous User
81

image

I did an n^2 solution and it TLEd on 2 cases. The only thing that comes to mind is union find, but I haven't tried implementing yet. Any ideas?

Comments (2)