You are viewing a single comment's thread. Return to all comments →
My Java Solution
private static int solution(int[] arr, int n){ Arrays.sort(arr); int maxDistance = arr[0]; for(int i = 1; i < arr.length; i++){ int distance = (arr[i] - arr[i-1]) / 2; if(maxDistance < distance) maxDistance = distance; } int lastGap = (n-1) - arr[arr.length - 1]; return (lastGap < maxDistance) ? maxDistance : lastGap; }
Flatland Space Stations
You are viewing a single comment's thread. Return to all comments →
My Java Solution