Simple java code 5 ms beats 91 %
\n# Complexity\n- \n\n# Code\n\nclass Solution {\n    public int minimumDifference(int[] arr, int k) {\n        if(k==1){\n            return 0;\n        }\n   
\n# Complexity\n- \n![image.png](https://assets.leetcode.com/users/images/ca9395c7-3838-4a87-bab4-e042a6e20425_1703645631.4038453.png)\n# Code\n```\nclass Solution {\n    public int minimumDifference(int[] arr, int k) {\n        if(k==1){\n            return 0;\n        }\n        int n=arr.length;\n        Arrays.sort(arr);\n        int min=11111111;\n        for(int i=0;i<n-k+1;i++){\n            min=Math.min(min,arr[i+k-1]-arr[i]);\n        }\n        return min;\n    }\n}\n```
['Java']