138: Combination sum

Given an array of positive distinct integers and target sum, return all unique combinations of array items that add up to the given sum

Note: The same item can be used more than once

 

Example 1

Input:   array = [2, 3, 6, 7], sum = 8

Output:  [[2, 2, 2, 2], [2, 3, 3], [2, 6]]

Example 2

Input:   array = [2, 4, 8], sum = 15

Output:  []
Difficulty:Medium
Topic:Backtracking
Problem #:138