Created
January 7, 2021 06:15
-
-
Save ceth-x86/c08b862f24839c68073e53bc2571daf0 to your computer and use it in GitHub Desktop.
Revisions
-
ceth-x86 created this gist
Jan 7, 2021 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ class Solution: def longestPalindrome(self, s: str) -> str: res = "" for i in range(len(s)): res = max(self.helper(s, i, i), self.helper(s, i, i+1), res, key=len) return res def helper(self, s, l, r): while 0 <= l and r < len(s) and s[l] == s [r]: l -= 1; r += 1 return s[l+1:r]