You are viewing a single comment's thread. Return to all comments →
if(n==c.length){ return 0; } List list=new ArrayList<>(); int minDistance; int distance; int station;
for(int j=0;j<n;j++){ minDistance=Integer.MAX_VALUE; for(int i=0;i<c.length;i++){ station=c[i]; distance=Math.abs(j-station); if(distance<minDistance){ minDistance=distance; } } list.add(minDistance); } int result=list.stream().max(Integer::compare).orElse(0); return result;
Seems like cookies are disabled on this browser, please enable them to open this website
Flatland Space Stations
You are viewing a single comment's thread. Return to all comments →
Java
if(n==c.length){ return 0; } List list=new ArrayList<>(); int minDistance; int distance; int station;