You are viewing a single comment's thread. Return to all comments →
Java
arr.sort(Comparator.naturalOrder()); int minSub = Integer.MAX_VALUE; for (int i = 0; i <= arr.size() - k; i++) { int sub = arr.get(i + k - 1) - arr.get(i); if (sub < minSub) { minSub = sub; } } return minSub;
Seems like cookies are disabled on this browser, please enable them to open this website
Max Min
You are viewing a single comment's thread. Return to all comments →
Java