Java
\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        if (k <= 1)\n            return 0;\n        \n        Arrays.sort(nums);\n   
```\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        if (k <= 1)\n            return 0;\n        \n        Arrays.sort(nums);\n        int ans = Integer.MAX_VALUE;\n        \n        for (int i = 0; i < nums.length - k + 1; i++)\n            ans = min(ans, nums[i + k - 1] - nums[i]);\n        return ans;\n    }\n    \n    private int min(int n1, int n2) {\n        return n1 < n2 ? n1 : n2;\n    }\n}\n```
[]