Hi all,
I was trying this question. here is my solution using mo’s algo. For merging two clubs, I used DSU ( with path compression and weighted union ). I think my solution is O(q*sqrt(n)) (mo’s algorithm dominating the time complexity ). The solution is giving TLE on 3 test cases, which I fail to understand why.
Am I calculating the complexity wrong ?
Is there any way to make my solution pass without changing the logic ?
Please let me know.
@l_returns @aryanc403 ?? @anyone_willing_to_help