Skip to content

Instantly share code, notes, and snippets.

@danielcodes
Created March 27, 2020 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielcodes/5d74494cd49cb7fab7d87dc69973c105 to your computer and use it in GitHub Desktop.
Save danielcodes/5d74494cd49cb7fab7d87dc69973c105 to your computer and use it in GitHub Desktop.
252. Meeting rooms
# 252. Meeting rooms
def solve(ints):
# alternate approach is to check current with next
# in this case iteration stops on the second to last interval
if not ints:
return True
ints.sort(key=lambda x: x[0])
curr = ints[0]
for i in range(1, len(ints)):
if ints[i][0] < curr[1]:
return False
curr = ints[i]
return True
# ints = [[0,30], [5,10], [15,20]]
# ints = [[0,10], [11,20], [21,30]]
ints = [[0,10], [5,20]]
print(solve(ints))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment