确定范围是否重叠 [英] Determine if ranges overlap
本文介绍了确定范围是否重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
给定两个具有整数开始和结束时间的事件,E1 =(s1,e1),E2 =(s2,e2),执行快速布尔检查以查看事件是否重叠。
Given two events with integer start and end times, E1 = (s1, e1), E2 = (s2, e2), implement a quick boolean check to see if the events overlap.
我有解决方案,但我很想知道其他人想出了什么。
I have the solution, but I'm curious to see what others come up with.
编辑:好的,这是我的解决方案:
OK, here's my solution:
e1 > s2 || (s1 > s2 && e2 < s1)
推荐答案
bool overlap =(s1< = e2)&& (s2< = e1)
这篇关于确定范围是否重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文