sliding window
Intuition\nusing the concept of the sliding window to solve this problem\n\n# Approach\nin the approach we have take two index pointer head , tail\nhead used to
# Intuition\nusing the concept of the sliding window to solve this problem\n\n# Approach\nin the approach we have take two index pointer head , tail\nhead used to decribe the current window last element and tail decribe the last window element\n\n# Complexity\n- Time complexity:\n\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) {\n\n        int head=0,tail=0,ans=INT_MAX;\n        int n=nums.size();\n\n        sort(nums.begin(),nums.end());\n\n        for(head=0;head<n;head++){\n\n            if((head-tail+1)==k){\n\n//with the head-tail+1 we can calculate the size of curr window\n                //iska means tail par small wala hoga and head of large wala bcoz array is sorted\n            ans = min(ans,nums[head]-nums[tail]);\n            tail++;\n\n            }\n           \n\n\n\n        }\n        return ans;\n        \n    }\n};\n```
['C++']