← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Given an integer array nums and a positive integer k, return the k-th largest sum of any subsequence of nums. A subsequence is any subset of the array (including the empty subset) and its sum is the sum of its elements. The empty subsequence has sum 0. You may assume that the total number of distinct subsequence sums is at least k.
Design an algorithm that computes the k-th largest subsequence sum efficiently without generating all 2^n subsets explicitly.