✔️Java solution | Sliding window | O(n) time complexity | Easy to understand
Here\'s my code with O(n) complexity :\n```\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n       if(nums.length==1){\n          retu
Here\'s my code with O(n) complexity :\n```\nclass Solution {\n    public int minimumDifference(int[] nums, int k) {\n       if(nums.length==1){\n          return 0; \n       }\n        Arrays.sort(nums);\n        int min = Integer.MAX_VALUE;\n        int diff = 0;\n        for(int e = k-1;e<nums.length;e++){\n            diff = nums[e] - nums[e-(k-1)];\n            min = Math.min(min,diff);\n        }\n        return min;\n    }\n}
['Sliding Window', 'Sorting', 'Java']