Skip to content

Instantly share code, notes, and snippets.

@supritashankar
Created February 11, 2016 01:54
Show Gist options
  • Save supritashankar/c4aa542c17238d20c191 to your computer and use it in GitHub Desktop.
Save supritashankar/c4aa542c17238d20c191 to your computer and use it in GitHub Desktop.
Meeting Calendar problem with sets
timeline = {
'1': set([0,1,2,3,4]),
'2': set([3,4,5,6,7]),
'3': set([2,3,4])}
def get_meeting_time(timeline):
"""
get intersection of all the person
"""
res = set([0,1,2,3,4,5,6,7,8,9])
maxres = set()
for x in timeline:
y = set(timeline[x])
res = y & res
if len(res) != 0:
maxres = res
print maxres
get_meeting_time(timeline)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment