Min Diff || Sliding Window || Two Pointer || Sorting
Intuition\nSort it and then run a sliding window of size K.\n\n# Approach\n Describe your approach to solving the problem. \nSort the Array.\n\nSo now for every
# Intuition\nSort it and then run a sliding window of size K.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nSort the Array.\n\nSo now for every K number of elements(i.e. One window) the *max = last element* of that window and the *min = first element* of that window. Determine the difference.\n\nLikeways do it for all the window of size K and determine the differnece. \n\nInitialized the difference as the Maximum value of Integer so that I can get the desired minimum difference.\n\n```\ndiff = Math.min(diff, nums[r++] - nums[l++]);\n```\n`nums[r++] - nums[l++]` = difference between the max and min.\n\n\n\n# Complexity\n- Time complexity:\nO(NlogN)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        Arrays.sort(nums);\n        int l = 0;\n        int r = l + k - 1;;\n        int diff = Integer.MAX_VALUE;\n        while(r < nums.length){\n            diff = Math.min(diff, nums[r++] - nums[l++]);\n        }\n        return diff;\n    }\n}\n```
['Two Pointers', 'Sliding Window', 'Sorting', 'Java']