Python 3 || C++ || O(nlogn) || Easy Solution
Python 3:\n\tclass Solution:\n\t\tdef minimumDifference(self, nums: List[int], k: int) -> int:\n\t\t\tnums.sort()\n\t\t\tl, r = 0, k-1\n\t\t\tres = float("inf")
## Python 3:\n\tclass Solution:\n\t\tdef minimumDifference(self, nums: List[int], k: int) -> int:\n\t\t\tnums.sort()\n\t\t\tl, r = 0, k-1\n\t\t\tres = float("inf")\n\n\t\t\twhile r < len(nums):\n\t\t\t\tres = min(res, nums[r] - nums[l])\n\t\t\t\tl, r = l+1, r+1\n\n\t\t\treturn res\n\n## C++:\n\n\tclass Solution {\n\tpublic:\n\t\tint minimumDifference(vector<int>& nums, int k) {\n\t\t\tsort(nums.begin(), nums.end());\n\n\t\t\tint l = 0, r = k-1, res=INT_MAX;\n\n\t\t\twhile (r < nums.size()){\n\t\t\t\tres = min(res, nums[r] - nums[l]);\n\t\t\t\tl++; r++;\n\t\t\t}\n\n\t\t\treturn res;\n\t\t}\n\t};
['C', 'Python']