Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

UNIONSET Doubt

$
0
0

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)


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>