mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-05 15:38:46 +08:00
fix salary assert method
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
export function hasIntersection(interval1, interval2) {
|
||||
// 通用函数:将区间标准化,null转换为对应的无穷大
|
||||
const normalizeInterval = (interval) => {
|
||||
const [start, end] = interval;
|
||||
return [
|
||||
[null, undefined].includes(start) ? -Infinity : start,
|
||||
[null, undefined].includes(end) ? Infinity : end
|
||||
];
|
||||
};
|
||||
|
||||
const [norm1Start, norm1End] = normalizeInterval(interval1);
|
||||
const [norm2Start, norm2End] = normalizeInterval(interval2);
|
||||
|
||||
// 判断交集
|
||||
return Math.max(norm1Start, norm2Start) <= Math.min(norm1End, norm2End);
|
||||
}
|
||||
Reference in New Issue
Block a user