link to question : https://www.codechef.com/JUNE17/problems/UNIONSET
My code gives only 40 pt for Unionset when i do it using set based approach in which i take union of two set
by putting element of both set in a single set(new set) and if size of set(new set) equals to K then i do
sum++ but it shows TLE
even when set insert take O(lg n).
On the other hand using hashing approach gives 100 pts .
Cant understand why set based approach is not working.
link to set based approach : https://www.codechef.com/viewsolution/14160598
link to hashing based approach : https://www.codechef.com/viewsolution/14160764
Time complexity : O(T(N^2)K)) (HASHING BASED APPROACH)