Created
September 21, 2021 23:53
-
-
Save go-cristian/76cacfc52bb8688a8b485b6cdfe1984e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flatlandSpaceStations(n, c) { | |
let max = 0 | |
if (n == c.length) { | |
return 0 | |
} | |
for(let i = 0; i < n; i++){ | |
var min = Math.abs(i - c[0]) | |
for (let j=0; j < c.length; j++) { | |
const distance = Math.abs(i-c[j]) | |
if (distance < min) { | |
min = distance | |
} | |
} | |
if(min > max){ | |
max = min | |
} | |
} | |
return max | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment