PERSISTENT SYSTEMS Hiring | Off-Campus OA (2024) | Minimum Difference Between Highest and Lowest of K Scores

Question · Posted Jun 2026

Problem Statement You are given an integer array nums, where each element represents a student's score, and an integer k. Your task is to select exactly k scores from the array such that the difference between the highest and lowest selected scores is minimized. Return the minimum possible difference. Example 1 Input nums = [90] k = 1 Output 0 Explanation Only one score is selected. Maximum = 90 Minimum = 90 Difference = 0 Example 2 Input nums = ...

The full answer & interview discussion are available to premium members.

Log in Create a free account