举例 1.2-1.5 , 1.4-1.6
去重后就是 1.2 1.3 1.4 1.5 .16 一共5天
function getDays (ranges: readonly (readonly [number, number])[]): number {
const days = new Set<number>();
for (const [start, end] of ranges) {
for (let time = start; end >= time; time += 8.64e7) {
days.add(time);
}
}
return days.size;
}
getDays([
[Date.parse("2021-01-02"), Date.parse("2021-01-05")],
[Date.parse("2021-01-04"), Date.parse("2021-01-06")],
]);