Skip to content

Instantly share code, notes, and snippets.

@dionisos2
Created November 11, 2018 19:40
Show Gist options
  • Save dionisos2/a68f9c7078fc09c29a64fc5d297ca7f3 to your computer and use it in GitHub Desktop.
Save dionisos2/a68f9c7078fc09c29a64fc5d297ca7f3 to your computer and use it in GitHub Desktop.
from collections import Counter
def stonesForCrown(stones):
c = Counter(stones)
num = 0
val = 0
l = sorted(c.items(), key = lambda x:(x[1], x[0]), reverse=True)
for x in l:
if num != x[1]:
num = x[1]
val = x[0]
else:
return val
else:
return -1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment