EASYasked at 1 company

Minimum Difference Between Highest and Lowest of K Scores

A easy-tier problem at 59% community acceptance, tagged with Array, Sliding Window, Sorting. Reported in interviews at Tinkoff and 0 others.

Founder's read

Tinkoff asked this problem, and it's easier than it sounds. You're given an array of scores and need to pick K of them such that the difference between the max and min in your selection is as small as possible. Most candidates overthink the sorting step and miss the sliding window entirely. The acceptance rate sits around 59%, which means a solid chunk of people either nail it fast or get stuck on the approach. If you see this in your live OA and blank on the window trick, StealthCoder solves it in seconds while the proctor sees nothing.

Companies asking
1
Difficulty
EASY
Acceptance
59%

Companies that ask "Minimum Difference Between Highest and Lowest of K Scores"

If this hits your live OA

Minimum Difference Between Highest and Lowest of K Scores 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.

Get StealthCoder
What this means

The key insight is that once you sort the array, the optimal K-element subarray must be contiguous. There's no benefit to picking non-adjacent elements after sorting because you'd only increase the spread. So the algorithm is dead simple: sort, then slide a window of size K across the sorted array, tracking the minimum difference between the last and first element in each window. Most wrong answers come from either forgetting to sort first or trying to use a multi-pointer approach on an unsorted array. The Array, Sliding Window, and Sorting topics are all in play here, though Sorting does the real work. This is a classic problem where the tricky part isn't the algorithm but recognizing that sorting makes the problem trivial. If you hit this during assessment and the sliding window doesn't click immediately, StealthCoder runs invisibly and surfaces the solution.

Pattern tags

The honest play

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

Minimum Difference Between Highest and Lowest of K Scores 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. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Minimum Difference Between Highest and Lowest of K Scores interview FAQ

Why does sorting make this problem easier?+

Sorting guarantees that the smallest spread of K elements is a contiguous subarray in the sorted list. Without sorting, you'd need to try many non-contiguous combinations. After sorting, you only check K different windows, each of size K, making it O(n log n) instead of exponential.

What's the exact sliding window approach?+

Sort the array. Create a window of size K starting at index 0. Slide it one position at a time, and for each window, compute the difference between array[i+K-1] and array[i]. Track the minimum difference across all windows. That's it.

Is this still asked by top companies?+

Tinkoff has asked it, and it's categorized as Easy, so it appears in early-stage assessments and phone screens. It's not a FAANG staple, but smaller to mid-tier tech companies use it for baseline algorithmic thinking.

What are common mistakes?+

Forgetting to sort the array, trying to optimize without sorting first, using a hash set instead of a window, or off-by-one errors in the window bounds. Also, some candidates try to use a heap or priority queue unnecessarily.

How long should this take in a real interview?+

If you recognize the pattern, code and test in under 10 minutes. If you don't, you can derive it in 15-20 by thinking through why sorting helps. The acceptance rate of 59% suggests many people get there, just not instantly.

Want the actual problem statement? View "Minimum Difference Between Highest and Lowest of K Scores" 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.