Skip to content

Instantly share code, notes, and snippets.

@sarchertech
Created January 24, 2015 06:16
Show Gist options
  • Save sarchertech/35d6684c7887db90c0b5 to your computer and use it in GitHub Desktop.
Save sarchertech/35d6684c7887db90c0b5 to your computer and use it in GitHub Desktop.
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