Skip to content

Instantly share code, notes, and snippets.

@MrMeison
Created June 13, 2018 08:12
Show Gist options
  • Save MrMeison/5a0b8341eb74a52af79058d3eb672f1e to your computer and use it in GitHub Desktop.
Save MrMeison/5a0b8341eb74a52af79058d3eb672f1e to your computer and use it in GitHub Desktop.
def get_major(items):
map = {}
major_count = round(len(items) / 2)
for item in items:
if map.get(item):
if map[item] + 1 >= major_count:
return item
map[item] = map[item] + 1
else:
map[item] = 1
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment