Created
March 16, 2020 16:25
-
-
Save flexbox/c11f900d5338900b5eed07b5abf4a7ff to your computer and use it in GitHub Desktop.
airplane-sorting-algorithm.js
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 solution(N, S) { | |
const occupied = S.split(' ') | |
let available = 0 | |
console.log("solution -> available", available) | |
for (let index = 0; index < N; index++) { | |
if ( | |
occupied[index] === `${index + 1}A` || | |
occupied[index] === `${index + 1}B` || | |
occupied[index] === `${index + 1}C` || | |
occupied[index] === `${index + 1}D` || | |
occupied[index] === `${index + 1}E` || | |
occupied[index] === `${index + 1}F` || | |
occupied[index] === `${index + 1}I` || | |
occupied[index] === `${index + 1}J` || | |
occupied[index] === `${index + 1}K` | |
){ | |
available++ | |
} | |
} | |
console.log("solution -> available", available) | |
return available | |
} | |
const two = solution(2, '1A 2F 1C') | |
console.log("available", two) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment