Created
October 9, 2018 23:16
-
-
Save FlorianWendelborn/b2460266b1a4121ef8d45b16a0bb66e8 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
const appointments = [[100, 125], [200, 230], [230, 400]] | |
const requests = [[10, 50], [130, 210], [240, 250]] | |
const times = [[0]] | |
for (let i = 0; i < appointments.length; i++) { | |
const [ra, rb] = appointments[i] | |
const last = times[times.length - 1] | |
last[1] = ra | |
times.push([rb]) | |
} | |
const results = requests.filter(([a, b]) => { | |
for (let i = 0; i < times.length; i++) { | |
const [x, y] = times[i] | |
if (a >= x && b <= y) return true | |
} | |
return false | |
}) | |
console.log(results) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment