且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

组合/合并日期范围的算法

更新时间:2021-07-07 10:13:32

按开始日期排序.

然后迭代并检查下一个项目的开始日期是在当前项目的结束日期之前还是之后.如果是,则将下一个合并到当前一个.然后继续.

Then iterate through and check for if the next item's start date is before or directly after the current one's end date. If it is, then merge the next one into the current one. Then continue.