You are viewing a single comment's thread. Return to all comments →
"Ok I figured it out; also, new solution, more finesse."
static int flatlandSpaceStations(int n, int[] c) {
if (n == c.length) { return 0; } int longest = 0; for (int i = 0; i < n; i++) { int shortest = Math.abs(i - c[0]); for (int j = 0; j < c.length; j++) { if (shortest > (Math.abs(i - c[j]))) { shortest = Math.abs(i - c[j]); } } if (shortest > longest) { longest = shortest; } } return longest; }
Flatland Space Stations
You are viewing a single comment's thread. Return to all comments →
"Ok I figured it out; also, new solution, more finesse."
static int flatlandSpaceStations(int n, int[] c) {