Skip to content

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.

Easy#1984
LeetCode Problem

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

Input
nums = [90], k = 1
Output
0

# Example 2

Input
nums = [9,4,1,7], k = 2
Output
2

Constraints

1 <= k <= nums.length <= 1000
0 <= nums[i] <= 10^5

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.