JAVA | Sorting | Sliding Window
Please Upvote :D\n\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        if (k == 1) return 0;\n\n        Arrays.sort(nums);\n\t\t\n
### **Please Upvote** :D\n```\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        if (k == 1) return 0;\n\n        Arrays.sort(nums);\n\t\t\n        int i = 0, j = k - 1, \n        min = Integer.MAX_VALUE;\n\n        while (j < nums.length) {\n            min = Math.min(min, nums[j++] - nums[i++]);\n        }\n\n        return min;\n    }\n}\n\n// TC: O(n * logn) + O(n) => O(n * logn)\n// SC: O(1)\n```
['Sliding Window', 'Sorting', 'Java']