Practice Find Subsequence of Length K With the Largest Sum
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Find Subsequence of Length K With the Largest Sum
Problem Statement
You are given an integer array nums and an integer k. You want to find a subsequence of nums of length k that has the largest sum. Return any such subsequence as an integer array of length k. 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.
Source: Find Subsequence of Length K With the Largest Sum on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [2,1,3,3], k = 2
[3,3]
# Example 2
nums = [-1,-2,3,4], k = 3
[-1,3,4]
# Example 3
nums = [3,4,3,3], k = 2
[3,4]
Constraints
Related LeetCode Problems
Practice more problems similar to Find Subsequence of Length K With the Largest Sum.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.