Python || C++ ||  Just sort
Python\n\nclass Solution:\n    def minimumDifference(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        answer=9999999999\n        for i in ra
Python\n```\nclass Solution:\n    def minimumDifference(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        answer=9999999999\n        for i in range(0,len(nums)-k+1):\n            val=nums[i+k-1]-nums[i]\n            answer=min(answer,val)\n        return answer\n        \n```\n\n\nC++\n```\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) {\n        sort(nums.begin(),nums.end());\n        int answer=INT_MAX;\n        for(int i=0;i<nums.size()-k+1;i++){\n            int val=nums[k+i-1]-nums[i];\n            answer=min(answer,val);\n        }\n        return answer;\n    }\n};\n```
[]