I want to count the subsets of a
with k
subset elements which sum to n
. The possible subset elements are defined through a given array a
with distinct positive elements. Possible subset elements can be just choosen once per subset. How Can i do this? Optimal without iterating through all subsets.
Example:
n := 10
k := 3
a := 1,2,6,7,8
=> 1 ( 1,2,7 )