Created
January 12, 2021 14:17
-
-
Save ceth-x86/28c2f065b44a59abab08ffbccc276f8a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def merge(self, intervals): | |
out = [] | |
for i in sorted(intervals, key=lambda i: i.start): | |
if out and i.start <= out[-1].end: | |
out[-1].end = max(out[-1].end, i.end) | |
else: | |
out += i, | |
return out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment