You are viewing a single comment's thread. Return to all comments →
java 8 solution
ArrayList<Long> newarr=new ArrayList<>(price); Collections.sort(price); long min=Long.MAX_VALUE; for(int i=0;i<newarr.size()-1;i++) { int k=Collections.binarySearch(price, newarr.get(i)); if(k==0) { price.remove(k); continue; } long min_l=(price.get(k)-price.get(k-1)); if(min_l<min) { min=min_l; } price.remove(k); } return min;
Seems like cookies are disabled on this browser, please enable them to open this website
Minimum Loss
You are viewing a single comment's thread. Return to all comments →
java 8 solution