Parity mean odd or even.
Thanks @vijju123 for replying…
I didn’t meant that over all will be O(n²) or O(n*q)…
By O(n) I meant that per query it would be size of smaller node…
And yes I agree O(Nlogn) is overall complexity…
Disjoint Set Data Structure but Basically you would require trick of merging two sets. i.e DSU trick