Created
April 18, 2016 10:29
-
-
Save xuefeng-huang/8d255586e72f2e8bf47ecdc96cd8b402 to your computer and use it in GitHub Desktop.
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
def longest_palindrome(s): | |
for i in range(len(s), 0, -1): | |
for j in range(len(s)-i+1): | |
sub = s[j:j+i] | |
if sub == sub[::-1]: | |
return i | |
return 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment