Same as previous problem with slight change


#1

def init(self):
self.subset=[]

def real(self,comb,target,curr,ind,A1):
    if(curr==target):
        if(comb not in self.subset):
            self.subset.append(list(comb))
    for i in range(ind,len(A1)):
        #print("index:",i,"element:",A1[i])
        
        if(curr+A1[i]>target):
            #print("pop++++++++")
            break
        comb.append(A1[i])
        #print("comb",comb)
        #print("sum-----",curr+A1[i])
        #print()
        
        self.real(comb,target,curr+A1[i],i+1,A1)
        #print("POP@@@@@@@@@@")
        comb.pop()
    return(self.subset)


    

def combinationSum(self, A, B):
    A.sort()
    Z=self.real([],B,0,0,A)
    Z.sort()
    return(Z)