IOPC 2013: IOPC13G

I have tried solving this question CodeChef: Practical coding for everyone , but iam not able to figure out an algorithm, can any one explain/ideas about??

To find the largest possible subset, first find the count of relations of each number.
Now put all the numbers in the set. Then remove those numbers which have less than k relations from the subset and reduce the count of the relations of these numbers still in the subset.

Now some other numbers will have less than k relations due to the reduction. Remove them from the subset and continue this step till either the set is empty or all numbers left have at least k relations.

3 Likes

click here
This is my code.
Check whether you can understanding??
Plz support if you can follow…:wink:

2 Likes