Problem 43. Subset Sum

Given a vector v of integers and an integer n, return the the indices of v (as a row vector in ascending order) that sum to n. If there is no subset in v that sums to n, return an empty matrix []. You can assume that the answer will always be unique.


 >> v = [2, 3, 5];
 >> n = 8;
 >> subset_sum(v, n)
 ans =
      2     3

Solution Stats

31.2% Correct | 68.8% Incorrect
Last solution submitted on Aug 20, 2019

Problem Comments

Solution Comments

Recent Solvers705

Suggested Problems

More from this Author95