Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active November 19, 2015 05:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/d250d00e1bd7ae05d772 to your computer and use it in GitHub Desktop.
Save whatalnk/d250d00e1bd7ae05d772 to your computer and use it in GitHub Desktop.
TopCoder SRM 673 Div 2
from collections import defaultdict
class BearSong():
def countRareNotes(self, notes):
d = defaultdict(int)
for i in notes:
d[i] += 1
return(len([i for i in d.values() if i == 1]))
class BearSlowlySorts():
def minMoves(self, w):
w = list(w)
if w == sorted(w):
return 0
else:
minw = min(w)
maxw = max(w)
if minw == w[0]:
return 1
elif maxw == w[-1]:
return 1
elif maxw == w[0]:
if minw == w[-1]:
return 3
else:
return 2
else:
return 2
@whatalnk
Copy link
Author

@whatalnk
Copy link
Author

  • Easy
  • Med
  • Hard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment