You are viewing a single comment's thread. Return to all comments →
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);
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 →
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);