Practice Find the K-Sum of an Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given an integer array nums and a positive integer k. You can choose any subsequence of the array and sum all of its elements together. We define the K-Sum of the array as the kth largest subsequence sum that can be obtained (not necessarily distinct). Return the K-Sum of the array. A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. Note that the empty subsequence is considered to have a sum of 0.
Source: Find the K-Sum of an Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [2,4,-2], k = 5
2
# Example 2
nums = [1,-2,3,4,-10,12], k = 16
10
Constraints
Related LeetCode Problems
Practice more problems similar to Find the K-Sum of an Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.