Created
January 24, 2015 06:16
-
-
Save sarchertech/35d6684c7887db90c0b5 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 answer(meetings): | |
available_time = 0; | |
num_meetings = 0; | |
while meetings: | |
mdx = meeting_with_earliest_end_time(meetings) | |
m = meetings[mdx] | |
if m[0] >= available_time: | |
available_time = m[1] | |
num_meetings += 1 | |
meetings.pop(mdx) | |
return num_meetings | |
def meeting_with_earliest_end_time(meetings): | |
earliest_end_time_index = 0 | |
earliest_end_time = meetings[0][1] | |
for idx, val in enumerate(meetings): | |
if val[1] < earliest_end_time: | |
earliest_end_time_index = idx | |
earliest_end_time = val[1] | |
return earliest_end_time_index |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment