I didn’t get the subset one. It was a little bit confusing can I get the concept with one example. I tried to solve the codechef question but i failed.
Subset question didnt get it
if you want subset of 3 numbers , you iterate from 1 to pow(2,n)
now ex n=3;
001
010
011
100
101
110
111
now at the binary number differs at least at one place,
so , now at all places where we have “1” , we will count that index in the subset.
for ex say 5=“101”
now we have 1 at 0 place and 2nd place, so they will be included in the subset
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.