Python 99.70% time solution (beginner friendly)
\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \nSort the input array first so it is easier to work with, then implement sliding w
![Screenshot 2022-12-26 at 10.06.37 PM.png](https://assets.leetcode.com/users/images/d2266660-7868-44d6-9070-0820cc451cbe_1672121376.6683125.png)\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSort the input array first so it is easier to work with, then implement sliding window approach\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSort the input array so we can know what the lowest and highest number in the sliding window is easily; then use a loop to go through the array with a sliding window of length k, then the result will be the minimum of what it is currently and nums[right] - nums[left]\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(NlogN)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(N) from sorting\n# Code\n```\nclass Solution:\n    def minimumDifference(self, nums: List[int], k: int) -> int:\n        nums.sort()\n        result = float(\'inf\')\n        left = 0\n        for right in range(k - 1, len(nums)):\n            result = min(result, nums[right] - nums[left])\n            left += 1\n        return result\n```
['Sliding Window', 'Sorting', 'Python3']