90% Runtime, 85% Memory with Simple Code
\n\n# Approach\nres = nums[k-1] - nums[0]\nSince nums is sorted, nums[k-1] - nums[0] returns max dif.\n\nres = min(res, nums[i] - nums[i - k + 1])\nFrom window 
\n\n# Approach\n`res = nums[k-1] - nums[0]`\nSince nums is sorted, `nums[k-1] - nums[0]` returns max dif.\n\n`res = min(res, nums[i] - nums[i - k + 1])`\nFrom window of size k, the far left is the minimum \nand far right is the maximum value in the window since nums is sorted. \n`nums[i]` : Far right\n`nums[i - k + 1])` : Far left\nSo "far right" - "far left" returns min dif.\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution:\n    def minimumDifference(self, nums: List[int], k: int) -> int:\n        if len(nums) <= 1:\n            return 0\n\n        nums.sort()\n        res = nums[k-1] - nums[0]\n\n        for i in range(k, len(nums)):\n            res = min(res, nums[i] - nums[i - k + 1])\n\n        return res\n\n        \n```
['Python3']