Meta Interview Question

find all the combination of a specific sum in a array.

Interview Answer

Anonymous

Feb 7, 2017

Opt(k, i) = Opt(k - a[i], i) U Opt(k, i-1) where : 1. Opt(k, i) is the ways to get sum = k for subarrray a[0:i] 2. Sum(Positive Elements) <= k <= Sum(Negative Elements)