this code shows segmentation fault, please look into this
Segmentation fault
can you please specify the error or errors in my code, specially the one that causes segmentation fault
and i am not able to understand the variable count here, when there can be or cannot be subset with 0 sum, i shows 0 only.
for eg, 1 2 3 4 as input(sum!=0)
and 1 3 2 -3 as input (sum==0)
@akshatkaush
I’ve commented the errors in the code
Main issue was you did not write return in base case
Rest I’ve mentioned in code
iam not able to see the comments in either of the code, can you resend the correct code
can you take input as 1 3 2 4 instead of 1 3 2 -3, it’s still showing the same answer whereas it should be different as there is no subset with sum equal to 0.
and maybe you misunderstood my variable count, i had added it because there can be multiple subsets wits sum=0, so to display yes only once, i used count to check the occcurences of subsets with sum=0.
Hey @akshatkaush
I just checked my code for
1
4
1 3 2 4
It gave answer as zero, might be IDE issue at that time
As I understood the question you had to print number of subsets with sum 0 so I modified count according to that
then for input
1
4
1 3 2 -3
answer should be 1 as there as one subset i.e.{3,-3} with sum 0, still your code shows answer as 0.
in the question you have to print yes or no, i.e is there a subset with sum 0 or not, can be done by seeing if the value of count is greater than 0 or not.