Tap here to switch tabs
Problem
Submissions

Problem: Minimum Difference Between Highest and Lowest K Scores

Minimum Difference Between Highest and Lowest K Scores asks you to choose any k student scores from an array and return the smallest possible gap between the highest and lowest chosen scores.

Statement

You are given an integer array nums representing the scores of students and an integer k.

Choose the scores of any k students from nums such that the difference between the highest score and the lowest score among the chosen k scores is minimized.

Return the minimum possible difference.

Constraints:

  • 1≤1 \leq k ≤\leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Difference Between Highest and Lowest K Scores

Minimum Difference Between Highest and Lowest K Scores asks you to choose any k student scores from an array and return the smallest possible gap between the highest and lowest chosen scores.

Statement

You are given an integer array nums representing the scores of students and an integer k.

Choose the scores of any k students from nums such that the difference between the highest score and the lowest score among the chosen k scores is minimized.

Return the minimum possible difference.

Constraints:

  • 1≤1 \leq k ≤\leq nums.length ≤1000\leq 1000

  • 0≤0 \leq nums[i] ≤105\leq 10^5