가장 긴 팰린드롬 (Level 3)

정은경·2020년 11월 1일
0

1. 문제

2. 나의 풀이

def is_palindrome(s):
    if len(s)==1:
        return True
    mid = len(s)//2
    if len(s)%2 == 0:
        if s[:mid] == s[mid:][::-1]:
            return True
    else:
        if s[:mid] == s[mid+1:][::-1]:
            return True

def solution(s):
    max = 0
    for i in range(len(s)):
        for j in range(i, len(s)):
            temp = s[i:j+1]
            if is_palindrome(temp):
                if len(temp) > max:
                    max = len(temp)
    return max

3. 남의 풀이




4. 느낀 점

profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글