Practice Minimum Difference Between Highest and Lowest of K Scores
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Minimum Difference Between Highest and Lowest of K Scores
Problem Statement
You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student. You are also given an integer k. Pick the scores of any k students from the array so that the difference between the highest and the lowest of the k scores is minimized. Return the minimum possible difference.
Source: Minimum Difference Between Highest and Lowest of K Scores on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [90], k = 1
0
# Example 2
nums = [9,4,1,7], k = 2
2
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Difference Between Highest and Lowest of K Scores.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.