You are viewing a single comment's thread. Return to all comments →
public static int maxMin(int k, List<Integer> arr) { Collections.sort(arr); int min =Integer.MAX_VALUE; int cal; List<Integer> list; for(int i=0;i<=arr.size()-k;i++){ list=arr.subList(i, i+k); cal=list.get(list.size()-1)-list.get(0); if(cal<min){ min=cal; if(min==0){ return 0; } } } return min; }
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