C++|Sort and Sliding Window|O(nlogn) Time Complexity
\nint minimumDifference(vector<int>& nums, int k) {\n        if(k == 1)\n            return 0;\n        sort(nums.begin(),nums.end());\n        int max1 = nums[
```\nint minimumDifference(vector<int>& nums, int k) {\n        if(k == 1)\n            return 0;\n        sort(nums.begin(),nums.end());\n        int max1 = nums[k - 1] , min1 = nums[0];\n        int ans = max1 - min1;\n        for(int i = k ; i < nums.size() ; i++){\n            max1 = nums[i];\n            min1 = nums[i - k + 1];\n            int diff = max1 - min1;\n            if(ans > diff)\n                ans = diff;\n        }\n        return ans;\n    }\n```
['Array', 'Sliding Window']