Created
January 25, 2017 05:58
-
-
Save P1n3appl3/7e201e60b002563cd0a6e90a9e71f1cc to your computer and use it in GitHub Desktop.
coding challenge from dropbox
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
class Meeting(object): | |
def __init__(self, start, end): | |
self.start = start | |
self.end = end | |
def __str__(self): | |
return str(self.start) + ', ' + str(self.end) | |
def schedule(times): | |
times.sort(key=lambda m: m.start) | |
rooms = [times[0]] | |
maxRooms = 1 | |
for t in times[1:]: | |
rooms = [i for i in rooms if i.end > t.start] + [t] | |
maxRooms = max(maxRooms, len(rooms)) | |
return maxRooms | |
meetingList = [ | |
Meeting(start=10, end=17), | |
Meeting(start=23, end=30), | |
Meeting(start=15, end=25), | |
] | |
print schedule(meetingList) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment