diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -11,7 +11,7 @@
     def minimumDifference(self, nums: List[int], k: int) -> int:
         # sliding window
         nums.sort()
-        l, r = 0, k
+        l, r = 0, k - 1
         res = float("inf")
         while r < len(nums):
             res = min(res, nums[r] - nums[l])
