Created
June 13, 2018 08:12
-
-
Save MrMeison/5a0b8341eb74a52af79058d3eb672f1e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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