C++ Simple and Clean 4-Line Explained Solution
Idea:\nSort the array.\nThen, we use a window of size k and calculate the difference between the first and last element in the window.\nres will be the minimum 
**Idea:**\nSort the array.\nThen, we use a window of size k and calculate the difference between the first and last element in the window.\n`res` will be the minimum of these values.\n**Time Complexity:** O(nlogn)\n**Space Complexity:** O(1)\n```\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) {\n        sort(nums.begin(), nums.end());\n        int res = nums[k-1] - nums[0];\n        for (int i = k; i < nums.size(); i++) res = min(res, nums[i] - nums[i-k+1]);\n        return res;\n    }\n};\n```\n**Like it? please upvote!**
['C']