Last active
November 19, 2015 05:55
-
-
Save whatalnk/d250d00e1bd7ae05d772 to your computer and use it in GitHub Desktop.
TopCoder SRM 673 Div 2
This file contains 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
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])) |
This file contains 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Editorial of SRM #673 - Codeforces