1984. Minimum Difference Between Highest and Lowest of K Scores

  Рет қаралды 31

CodeVia

CodeVia

Күн бұрын

1984. Minimum Difference Between Highest and Lowest of K Scores #leetcode #googleinterview #java #leetcodequestionandanswers #javainterviewquestions #microsoftinterview #amazoninterviewpreparation #coding
leetcode.com/p...
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.
Example 1:
Input: nums = [90], k = 1
Output: 0
Explanation: There is one way to pick score(s) of one student:
- [90]. The difference between the highest and lowest score is 90 - 90 = 0.
The minimum possible difference is 0.
Example 2:
Input: nums = [9,4,1,7], k = 2
Output: 2
Explanation: There are six ways to pick score(s) of two students:
- [9,4,1,7]. The difference between the highest and lowest score is 9 - 4 = 5.
- [9,4,1,7]. The difference between the highest and lowest score is 9 - 1 = 8.
- [9,4,1,7]. The difference between the highest and lowest score is 9 - 7 = 2.
- [9,4,1,7]. The difference between the highest and lowest score is 4 - 1 = 3.
- [9,4,1,7]. The difference between the highest and lowest score is 7 - 4 = 3.
- [9,4,1,7]. The difference between the highest and lowest score is 7 - 1 = 6.
The minimum possible difference is 2.

Пікірлер
Score of Parentheses | Live Coding with Explanation | Leetcode - 856
9:27
Algorithms Made Easy
Рет қаралды 6 М.
Unveiling my winning secret to defeating Maxim!😎| Free Fire Official
00:14
Garena Free Fire Global
Рет қаралды 17 МЛН
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 48 МЛН
LeetCode 1493 Longest Subarray of 1's After Deleting One Element
6:12
Defuse the Bomb  | Leetcode 1652 | Amazon Google Facebook interview question
14:46
3271  Hash Divided String
8:08
CodeCracker
Рет қаралды 15
LeetCode Long Pressed Name Solution Explained - Java
7:30
Nick White
Рет қаралды 8 М.
Java Collections Explained (with examples)
10:39
Visual Computer Science
Рет қаралды 81 М.
Arranging Coins [ Leetcode - 441
2:57
Algorithms Made Easy
Рет қаралды 2,3 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 803 М.