It's my fu**ing  code... Beat 100 % .... Wanna learn something New Today  ?????
Intuition\n:: Sorting and pointers\n\n# Approach\n\ni.e for {1,3,4,6,7,8},and k=3 ;\ncompae difference of :: (1,4),(3,6),(4,7),(6,8).. just this is enough\n// s
# Intuition\n**:: Sorting and pointers**\n\n# Approach\n<first sort and than compare the difference of the boundary elements for the window of k consecutive elements >\ni.e for {1,3,4,6,7,8},and k=3 ;\ncompae difference of :: (1,4),(3,6),(4,7),(6,8).. just this is enough\n// so our ans will min of(ans , diff(right bound - left bound ));;\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& v, int k) {\n        std::sort(v.begin(),v.end()); \n    // first sort ,, Why ???\n    // Ans :: So that all term inside window excluding the boundary\n    // all are inside the boundary of window ..\n\n        k--;            // K-1 will be used many time so i did it --;\n\n        int ans=v[k] - v[0];  \n    // U can also assign ans with INT MAX but no need ...\n\n        int i=v.size()-k;\n        while(i--){     // My window is moving from end \n    // U can start from first ,.. no big deal .. \n\n            ans=min(ans,(v[i+k]-v[i])); // Updatng ans.\n        }\n        return ans;\n    }\n};\n```
['Sorting', 'C++']