I was solving this as mentioned in the video, but don’t know why my code is not working.
Code: https://ideone.com/8jb6dY
Problem: https://www.spoj.com/problems/SUBSUMS/
Spoj SUBSUMS Problem
i modifies your solution !
PS.
we you want (2^n) then you shift (1<<n) not (2<<n)!.
Still getting wrong answer on submission…any guess what I’m doing wrong here
the solution i posted above is giving correct answer and is accepted on SPOJ.
Where’s the link of your code…?
brother jo maine tera solution modify kiya hai just above, woh sahi solution hai ,
iss post pr mera first comment dekh , this solution is yours, i have modified it,
and it is giving a corect answer on submission
this one
Ohh sorry I haven’t saw it.
I can found 2 changes in my code, first one is you replaced 2 with 1 for finding range which is correct but I cannot understand why you inserted 0 at the end of the subset sum. What was the purpose behind that? Can you please make it clear why you did so
i changed 2 with one because pow(2,n)=1<<n;
secondly as given in the question if you read it completely , it says that you have to consider empty subsequence also whose value s 0.
Thanks
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.