I've taken online test for amazon on hacker rank. Could not pass all the test cases for the same. Would like too see what would be the ideal approach for this.
Given an array of numbers(positive and negative) return the top k most combination sum(sorted).
Sample case
[5,3,-2]
possible combinations sums: 5, 3, -2, 8, 6, 1, ..
answer - [8,6,5]