/
githubmirror
/
tech-interview-handbook
Обзор
Документация
Войти
/
githubmirror
/
tech-interview-handbook
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
apps/website/experimental/utilities/javascript/intervalsIntersect.js
17 строк
807 B
Yangshun Tay
website: move into monorepo
01 окт 2022, 03:22
01 окт 2022, 03:22
7f621eb
Код
Авторство
О чём код?
// Interval: [start, end]. function intervalsIntersect(a, b) { return a[0] < b[1] && b[0] < a[1]; } console.log(intervalsIntersect([1, 2], [3, 4]) === false); console.log(intervalsIntersect([1, 2], [2, 4]) === false); console.log(intervalsIntersect([1, 2], [1, 4]) === true); console.log(intervalsIntersect([1, 2], [0, 4]) === true); console.log(intervalsIntersect([1, 2], [0, 2]) === true); console.log(intervalsIntersect([1, 2], [0, 1.5]) === true); console.log(intervalsIntersect([3, 4], [1, 2]) === false); console.log(intervalsIntersect([2, 4], [1, 2]) === false); console.log(intervalsIntersect([1, 4], [1, 2]) === true); console.log(intervalsIntersect([0, 4], [1, 2]) === true); console.log(intervalsIntersect([0, 2], [1, 2]) === true); console.log(intervalsIntersect([0, 1.5], [1, 2]) === true);