Created
October 28, 2013 12:03
-
-
Save cocodrips/7195711 to your computer and use it in GitHub Desktop.
SRM595 Div2 250
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
class LittleElephantAndBallsAgain: | |
def getNumber(self, S): | |
c = S[0] | |
longest = 0 | |
l = 1 | |
for s in S[1::]: | |
if s != c: | |
longest = max(longest, l) | |
l = 1 | |
c = s | |
else: | |
l += 1 | |
longest = max(longest, l) | |
return len(S) - longest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment