java 4ms
Here is my code \n\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        int n=nums.length;\n        if(k>n ) return -1;\n        Ar
Here is my code \n```\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n        int n=nums.length;\n        if(k>n ) return -1;\n        Arrays.sort(nums);\n        int min =nums[k-1]-nums[0];\n        for(int i=1;i+k-1<n;i++)\n            min=Math.min(min,nums[i+k-1]-nums[i]);\n        \n        return min;\n        \n    }\n}\n```
['Java']