Created
January 19, 2017 07:13
-
-
Save phondanai/0c73d37c01310bfe08b6d6bc4ed80dfd to your computer and use it in GitHub Desktop.
Stupid solution of print longest sequence of character from string s
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
s = 'azcbobobegghakl' | |
result = '' | |
tmp = '' | |
for i in range(len(s)-1): | |
if s[i] <= s[i+1]: | |
tmp += s[i] | |
if i == len(s) - 2: | |
tmp += s[i+1] | |
if len(tmp) > len(result): | |
result = tmp | |
else: | |
tmp += s[i] | |
if len(tmp) > len(result): | |
result = tmp | |
tmp = '' | |
print("Longest substring in alphabetical order is: " + result) | |
# Longest substring in alphabetical order is: beggh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment