Can somebody explain me the pseudo code of doing this?

stuck in logic , but i know the rec would be called such that including the element or not

@Muskan-Gupta-598128740703036
hello Muskan,
step 1-> get all unique elements from given array
step 2-> sort them in increasing order
step 3-> apply ur recursion logic to generate all subsequence and print those subsequence whose sum is equal to the given target

toh duplicate elements jo array mei hoge unka kya??

vo bhi toh subsequence ka part ho sakte hai

@Muskan-Gupta-598128740703036
yeah u r right but
image

wo saare subsequence jisme koi number ek se jayda baar repeat ho raha hoga wo to discard ho jayenge kyunki question me mentioned hai ki repetetion allowed nahi hai

sir isme hashset mei values increasing order mei kaise aaygi???

@Muskan-Gupta-598128740703036
hello muskan,
convert hash set to tree set.

java.util.ArrayList cannot be cast to java.lang.Comparable -----this compilation error is showing…actually i am not able to find out treeset of arraylist on google also…so help

@Muskan-Gupta-598128740703036
it think comparator of tree set dont work for array so either define ur own comparator or instead of array store ur sequence as string .

for example if 1,2,3 is making the target sum then store 123 in ur tree set

sir output mei boxes aare hai ?? :frowning:

@Muskan-Gupta-598128740703036
in line no 28 ,dont convert integer to char
kyunki phir wo integer ko ascii value treat karega aur integer ko uske correspondig character me convert kar dega.

for example-> agar integer (l) 65 hai to
char ch=(char)l will convert 65 to A .

so directly string me integer add kar do .
matlab ki
str=str+l

finally done , but still 2 test cases are passed out of 4,…one is WA and another is showing runtime

@Muskan-Gupta-598128740703036
share ur updated code

@Muskan-Gupta-598128740703036
a) in line no 17 it should j<n
b) in line no 25 it should be k < n

image
add extra check to avoid repetetion of same number

sir samjh nhi aaya , output shi toh hai …1 1 1 and 1 2 …?? toh correct ka hogi fir?

@Muskan-Gupta-598128740703036
1 1 1 incorrect hai kyunki 1 tin baar aa gya hai ,koi number kisi sequence me ek hi baar aa sakta hai