I have a list of time entries (HHMM format) with a start time and a stop. I\'m having trouble figuring out how to code it in Python where it returns if there\'s an overlap o
For future reference, the solution of @Roy doesn't work for intervals that have the same end or start times. The following solution does:
intervals = [[100, 200], [150, 250], [300, 400], [250, 500], [100, 150], [175, 250]]
intervals.sort()
l = len(intervals)
overlaps = []
for i in xrange(l):
for j in xrange(i+1, l):
x = intervals[i]
y = intervals[j]
if x[0] == y[0]:
overlaps.append([x, y])
elif x[1] == y[1]:
overlaps.append([x, y])
elif (x[1]>y[0] and x[0]
Also, an Interval Tree could be used for these kinds of problems.