Minimum Difference Between Highest and Lowest of K Scores (Leetcode 1984)
Problem Link: https://leetcode.com/problems/minimum-difference-between-highest-and-lowest-of-k-scores/
class Solution:
def minimumDifference(self, nums: List[int], k: int) -> int:
nums.sort()
n=len(nums)
ans=float('inf')
for i in range(n-k+1):
ans=min(ans,nums[i+k-1]-nums[i])
return ans
PreviousNumber of Substrings Containing All Three Characters (Leetcode 1358)Next*** Longest Nice Substring (Leetcode 1763)
Last updated