JavaScript - brute force with sliding window
\nvar minimumDifference = function(nums, k) {\n    nums.sort((a,b)=>a-b);\n    if(k===1)\n    {\n        return 0;\n    }\n    var n = nums.length;\n    var res
```\nvar minimumDifference = function(nums, k) {\n    nums.sort((a,b)=>a-b);\n    if(k===1)\n    {\n        return 0;\n    }\n    var n = nums.length;\n    var res = Infinity;\n    for(var i = 0; i<= n-k; i++)\n    {\n        res = Math.min(res, nums[i+k-1]-nums[i]);\n    }\n    return res;\n};\n```
['JavaScript']