SubsetSum Easy problems Approach


I am trying to do like this :

  1. firstly generate all the possible subsets and sum each subset to check whether the result is zero or not
    but here in the base case if am trying to access the elements which are not there like 0ton some subset have all the elements and some are not so how ho to solve it

hello @Vikaspal

add one more parameter in u function i.e count.
use it to maintain size of subset .

if in base case count is zero then it means subset is empty

@aman212yadav okay in each functions call i need to increment the value of count as the arrays is start growing

yeah …

@aman212yadav one more things related to subsequences problems
some case we are using
subsequence() /// call on the left side
out[j] = input[i]
subsequence()

And some case
out[j] = input[i]
subsequence() left part
subsequence() right part

what the really difference here beacause we are overwriting the values in the second case…

yeah that is the only difference.

@aman212yadav https://ide.codingblocks.com/s/288966
could please checkout this

@aman212yadav

what is ur doubt . . . . . . . . . . . . . . ?

@aman212yadav it printing out the some address randomly i am trying to print the all subset sum

image

do this will create array of size 1.
so do u want to create array of size one or anything else

check this ->

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.