Subset sum easy

subset can only of two numbers or can be more?

Hey @CODER_JATIN subset of an array 1, 2, 3
Is
@(null)
1
2
3
1 2
1 3
2 3
1 2 3

okay ji , thank you . . . . . . .

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.

https://ide.codingblocks.com/s/351523 , please check my code what is problem in this.?

hello @CODER_JATIN

a) u r not taking input correctly , u are given input as interger , char array will not work here.

b) ur code is also considering empty subset but empty subset is not allowed so handle that as well

bhaiya , thodi help karna kese karu fir isko.

@CODER_JATIN
generate all subset , then in base case check two conditions
a) generated subset is not empty
b) sum is zero
if these condiitons hold then return true
else
return false

it is showing segmentation fault , please have a look on it,

@CODER_JATIN

image

put return false; as last line of this if statement

bhaiya , abhi bhi galat hai,

@CODER_JATIN
check now->

bhaiya kya kya changes karey hai?

line 21,25,26 and 27

yeh cheez ni smjh aayi , why we are doing this (a||b)

ese bhi to kr skte hai ki agar ek call se true aa gya fir dusri call krne ki jarurat ni hai.

ha aur agar pehle se false aa gya tab dusra call karna jaruri hai

Hanji , chalo ek baar dry run krke dekh leta hu. :slight_smile:

https://ide.codingblocks.com/s/355211 , bhaiya dekhna ek baar ese bhi sahi hai naa?