Skip to content

Instantly share code, notes, and snippets.

@dayvsonlima
Created June 13, 2019 00:01
Show Gist options
  • Save dayvsonlima/197ca838e87abfaed63a4da6c4e8e593 to your computer and use it in GitHub Desktop.
Save dayvsonlima/197ca838e87abfaed63a4da6c4e8e593 to your computer and use it in GitHub Desktop.
def isPalindrome(input):
length = len(input)
half = length / 2
return input[0:(half)] == input[(length - half):length][::-1]
class Solution(object):
def longestPalindrome(self, input):
palindrome_size = len(input)
left = 0
right = palindrome_size
while(palindrome_size > 1):
while(right <= len(input)):
if(isPalindrome(input[left:right])):
return input[left:right]
else:
left+=1
right+=1
palindrome_size-=1
left = 0
right = palindrome_size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment