if we are given integers both neg and pos and we have to add min no of it to make a sum…(we can use any no as many times we want ) can’t we solve this by DP ??? i tried but its difficult like if the no’s are -5 -2 7 and we want sum of 5 for this if we solve like coin denomination problem then we need to know the future val like in this case we need to know the value of 10 (5-(-5)) if we use value at first ind
You can solve it by bitmasking . And whenever the sum of no.s represented by set bits equals to The required sum , then just count the no. of set bits.
P.S. : I am unable to come on a dp solution at a glance
Maybe Partition DP can be used to solve it , I have never used it so I am not sure