Runtime: 92 ms, faster than 100.00% of JavaScript online submissions
\nvar minimumDifference = function(nums, k) {\n    if (nums.length===1) return 0;\n    \n    nums.sort((a,b)=>a-b);\n    \n    let left = 0;\n    let right = k-
```\nvar minimumDifference = function(nums, k) {\n    if (nums.length===1) return 0;\n    \n    nums.sort((a,b)=>a-b);\n    \n    let left = 0;\n    let right = k-1;\n    \n    let min = Infinity;\n    \n    while (right<nums.length){\n        min = Math.min(min, nums[right]-nums[left]);\n        right++;\n        left++;\n    }\n    return min;\n};\n```\n![image](https://assets.leetcode.com/users/images/ea3a80e2-83fe-4a9f-9985-ef14bdac8b7e_1630256224.933265.png)\n
['JavaScript']