Three key points:
Allowing reuse means passing the same index (not ) to the recursive call.
Pruning (checking if sum exceeds target) avoids wasteful exploration.
Backtracking works for sum-based constraints just as well as size-based constraints.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
summary
Three key points:
Allowing reuse means passing the same index (not ) to the recursive call.
Pruning (checking if sum exceeds target) avoids wasteful exploration.
Backtracking works for sum-based constraints just as well as size-based constraints.