Expedia Coding Test

SubsequenceWithMaxSumUnderK

Given an array of integers and a value K find a subsequence having maximum sum under K.
Return the maximum Sum.

// Examples - 

nums = [1,2,3,4,5,6,7,16], K = 15
// ans = 15
// explaination = [1,2,3,4,5]

nums = [1,2,3,12,3], K = 10
// ans = 9
// explaination = [1,2,3,3]

Update:

I was able to get a DP solution (n^2) later.
Here is Link - https://leetcode.com/playground/kmgmn3pi

Comments (12)