Easiest Solution || C++ || Beginner Approach
Beats 75% in Time Complexity\n\n\n\n# Code\n\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) {\n        int n=nums.size();\n    
# Beats 75% in Time Complexity\n\n![Screenshot from 2024-03-23 17-20-37.png](https://assets.leetcode.com/users/images/fecc52e6-e202-488d-87aa-4a64ddb4b569_1711194647.9651191.png)\n\n# Code\n```\nclass Solution {\npublic:\n    int minimumDifference(vector<int>& nums, int k) {\n        int n=nums.size();\n        if(n==1){\n            return 0;\n        }\n\n        int minDiff=INT_MAX;\n        sort(nums.begin(), nums.end());\n        for(int i=0;i<=n-k;i++){\n            int min=nums[i+k-1]-nums[i];\n            if(min<minDiff){\n                minDiff=min;\n            }\n        }\n        return minDiff;\n    }\n};\n```
['C++']