Compare commits
3 commits
14e8b539c6
...
3e42548f95
Author | SHA1 | Date | |
---|---|---|---|
Bruno BELANYI | 3e42548f95 | ||
Bruno BELANYI | 8c1bf30b3f | ||
Bruno BELANYI | 1d93813e2d |
|
@ -31,8 +31,7 @@ def merge_intervals(intervals: Iterable[Interval]) -> list[Interval]:
|
|||
|
||||
res = [intervals[0]]
|
||||
for candidate in intervals[1:]:
|
||||
# Range is inclusive in both end, so add 1 to end in case of near miss
|
||||
if (res[-1].end + 1) >= candidate.start:
|
||||
if res[-1].end >= candidate.start:
|
||||
new_end = max(res[-1].end, candidate.end)
|
||||
res[-1] = Interval(res[-1].start, new_end)
|
||||
else:
|
||||
|
|
|
@ -31,8 +31,7 @@ def merge_intervals(intervals: Iterable[Interval]) -> list[Interval]:
|
|||
|
||||
res = [intervals[0]]
|
||||
for candidate in intervals[1:]:
|
||||
# Range is inclusive in both end, so add 1 to end in case of near miss
|
||||
if (res[-1].end + 1) >= candidate.start:
|
||||
if res[-1].end >= candidate.start:
|
||||
new_end = max(res[-1].end, candidate.end)
|
||||
res[-1] = Interval(res[-1].start, new_end)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue