최장 팰린드롬 문자열 찾기
https://leetcode.com/problems/longest-palindromic-substring/
class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
n = len(s)
for i in range(n-1):
for j in range(0,i+1):
ss = s[j:n-i+j]
if ss == ss[::-1]:
return ss
return s[0]
Time Limit Exceeded
현재 코드 계산량은
abcdef.(중략).xx 이런 경우, xx를 찾기위해서 의 작업을 해야함.
Next what to do
1. 짝수(2)-홀수(3) 투 포인터 사용
2. 작은 단위에서 확장하는 방식으로 코드 짜기