Leetcode - 125. Valid Palindrome
Coding Test

Leetcode - 125. Valid Palindrome

일시불

문제

Loading...
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

풀이

class Solution:
    def isPalindrome(self, s: str) -> bool:
        string_ascii = ''
        for char in s:
            ascii_code = ord(char)
            # Take care of Upper case characters
            if 65 <= ascii_code <= 90:
                string_ascii += chr(ascii_code + 32)
            # Lower case characters or digits
            elif 97 <= ascii_code <= 122 or 48 <= ascii_code <= 57:
                string_ascii += char
            # Ignored otherwise

        return string_ascii == string_ascii[::-1]