C++ | O(nlogn) time O(1) space | 14ms faster than 90% | 13.6MB less than 96%
Runtime: 14 ms, faster than 90.53% of C++ online submissions for Minimum Difference Between Highest and Lowest of K Scores.\nMemory Usage: 13.6 MB, less than 96
Runtime: 14 ms, faster than 90.53% of C++ online submissions for Minimum Difference Between Highest and Lowest of K Scores.\nMemory Usage: 13.6 MB, less than 96.30% of C++ online submissions for Minimum Difference Between Highest and Lowest of K Scores.\n\n```\nclass Solution \n{\npublic:\n    int minimumDifference(vector<int>& nums, int k) \n    {\n        std::sort(nums.begin(), nums.end());\n        \n        int mi = INT_MAX;\n        for (int i = 0; i <= nums.size() - k; i++)\n        {\n            mi = std::min(mi, nums[i + k - 1] - nums[i]);\n        }\n        return mi;\n    }\n};\n```
[]