Skip to content

Commit

Permalink
Create 1984-minimum-difference-between-highest-and-lowest-of-k-scores.py
Browse files Browse the repository at this point in the history
Code transcribed from the video https://www.youtube.com/watch?v=JU5XdBZZtlk
  • Loading branch information
AP-Repositories authored Dec 30, 2022
1 parent 2d0e0cc commit a81bcea
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Solution:
def minimumDifference(self, nums: List[int], k: int) -> int:
nums.sort()
l, r = 0, k - 1
res = float("inf")

while r < len(nums):
res = min(res, nums[r] - nums[l])
l, r = l + 1, r + 1
return res

0 comments on commit a81bcea

Please sign in to comment.