Last active
February 1, 2018 00:32
-
-
Save neanias/cbb0d5a16081f5f7e0a58aef72ed7ad0 to your computer and use it in GitHub Desktop.
MIT Problem
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
string = "abcadefzab" | |
longest_string = '' | |
current_string = '' | |
last_char = '' | |
for char in string: | |
if char >= last_char: | |
current_string += char | |
elif last_char > char: | |
if len(current_string) > len(longest_string): | |
longest_string = current_string | |
current_string = char | |
last_char = char | |
if len(current_string) > len(longest_string): | |
longest_string = current_string | |
print(longest_string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment