如何判断两个时间段是否重叠?

转载自: https://www.jianshu.com/p/e3fab50825fd

在这里插入图片描述
图片来自 https://blog.csdn.net/qq_33896101/article/details/82012300

现在有两个时间区间
A[A1,A2] B[B1,B2]
如何判断区间A和B存在重叠
Begin = Max(A1 , B1) ;
End = Min(A2 , B2) ;
Len = End - Begin
只要 Len >= 0 , 那么AB区间重叠, Len为重叠的长度

猜你喜欢

转载自blog.csdn.net/qq_38913715/article/details/123186378