Can you please tell what is the problem in my code?
@Ak07
Can you plz explain me your logic? Where are you checking whether your sum is equals to target or not. you aren’t even using target variable in the function.
also in the question we it is already given that target=0 so we dont have to input from the user
using the sum i am trying to calcluate the sum of that particular subset
Check line 11, 12 and 13. here first you are initializing b[j] with a[i], then makes sum=0 and then initialize sum with b[j]. This means that your sum=a[i], which is equals to zero only if a[i] is 0. I don’t think you are taking sum of subset. please check your code.
pass sum variable in function parameter. think this way
i did as you said and it is giving the correct answers when i tried by giving custom input but it is not passing the testcases
At the beginning of while loop, write count=0;
you have to initialize count with 0 for each testcase
thanks a lot, got it