Sliding Window solution in C++
Complexity\n- Time complexity: O(nlogn)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) 
# Complexity\n- Time complexity: $$O(nlogn)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) {\n        if(nums.size()==1) return 0;\n        sort(nums.begin(), nums.end());\n        int i=0, j=k-1, result=INT_MAX;\n        while(j<nums.size())\n        {\n            result= min(result, nums[j]-nums[i]);\n            i++; j++;\n        }\n        return result;\n    }\n};\n```
['Array', 'Two Pointers', 'Sliding Window', 'Sorting', 'C++']