We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Flatland Space Stations
Flatland Space Stations
Sort by
recency
|
949 Discussions
|
Please Login in order to post a comment
Is the custom comparator too much? Maybe. But it's funnier that way.
JAVA
static int flatlandSpaceStations(int n, int[] c) {
js my solution... if (n == c.length) return 0;
const lengthC = c.length - 1;
c.sort((a, b) => a - b); console.log(c);
let max = c[0]; for (let i = 0; i < lengthC; i++) { const tmp = Math.floor(c[i + 1] - (c[i + 1] + c[i]) / 2);
if (tmp > max) max = tmp; }
let lastOne = n - c[lengthC] - 1;
if (lastOne > max) max = lastOne;
console.log(max);