Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.