나는 이렇게 학습한다/Algorithm & SQL

1019. Is it a palindrome?

daco2020 2022. 10. 19. 23:45
반응형

Write a function that checks if a given string (case insensitive) is a palindrome.



Solution:

def is_palindrome(s):
    target = s.lower()
    for i in range(len(target)//2):
        if target[i] != target[-i-1]:
            return False
    return True
def is_palindrome(s):
    s = s.lower()
    return s == s[::-1]


반응형