EASYasked at 2 companies

Find Subsequence of Length K With the Largest Sum

A easy-tier problem at 46% community acceptance, tagged with Array, Hash Table, Sorting. Reported in interviews at Accenture and 1 others.

Founder's read

You need to pick K elements from an array and maximize their sum while preserving the original order. It sounds trivial until you realize the subsequence constraint means you can't just grab the K largest values and sort them back. Accenture and Oracle both ask this. The acceptance rate sits at 45%, which tells you most candidates solve it wrong on their first attempt. If you freeze on this during a live assessment, StealthCoder surfaces a working solution invisible to the proctor.

Companies asking
2
Difficulty
EASY
Acceptance
46%

Companies that ask "Find Subsequence of Length K With the Largest Sum"

If this hits your live OA

Find Subsequence of Length K With the Largest Sum is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The trap is thinking you can greedily pick the K largest numbers and rearrange them. You can't. A subsequence maintains relative order from the original array. The actual pattern: find the K largest elements (use a min-heap or sorting), then iterate through the array once and pick those elements in the order they appear. Common fail: forgetting to track which values you've already used, or trying to sort after selection. The heap approach works cleanly: build a heap of size K as you scan left-to-right, then do a second pass to extract in order. If this edge case hits you cold in the assessment, StealthCoder runs it in seconds and shows you the working code.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Find Subsequence of Length K With the Largest Sum recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find Subsequence of Length K With the Largest Sum interview FAQ

Why does greedy selection of K largest fail here?+

Subsequences preserve original array order. If you pick the K largest values and rearrange them, you've broken the constraint. You must find the K largest values first, then iterate the original array and collect them in the order they appear.

Is this really asked at Accenture and Oracle?+

Yes. Both companies appear in the reported data for this problem. It's a medium-difficulty logic check that screens for understanding the difference between subsequence and subarray constraints.

What's the optimal approach?+

Use a min-heap of size K to track the K largest elements as you scan the array. Once you've identified which K values to keep, do a second pass through the original array and collect them in order. Time: O(n log K), space: O(K).

How does this relate to sorting and heap topics?+

You need sorting or a heap to identify the K largest values efficiently. The heap is preferred because you only maintain K elements in memory, not a sorted copy of the entire array. Sorting the whole array then filtering also works but wastes time and space.

Why is the acceptance rate only 45%?+

Most candidates either forget the order constraint and sort the result, or implement inefficient two-pass logic. The trick is realizing you need to find the K largest first, then preserve order on the second scan. It's a pattern that requires a second read of the problem.

Want the actual problem statement? View "Find Subsequence of Length K With the Largest Sum" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.