Created
March 27, 2020 18:54
-
-
Save danielcodes/5d74494cd49cb7fab7d87dc69973c105 to your computer and use it in GitHub Desktop.
252. Meeting rooms
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
# 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