Skip to content

Instantly share code, notes, and snippets.

@ceth-x86
Created January 12, 2021 14:17
Show Gist options
  • Save ceth-x86/28c2f065b44a59abab08ffbccc276f8a to your computer and use it in GitHub Desktop.
Save ceth-x86/28c2f065b44a59abab08ffbccc276f8a to your computer and use it in GitHub Desktop.
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