본문 바로가기

IT/코딩테스트

[Leetcode] 9. Palindrome Number

728x90

https://leetcode.com/problems/palindrome-number/

 

LeetCode - The World's Leading Online Programming Learning Platform

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.

leetcode.com

class Solution:
    def isPalindrome(self, x: int) -> bool:

        str_x = str(x)
        max_index = len(str_x)

        for i in range(0, max_index):
            if str_x[i] == str_x[max_index - 1 - i]:
                continue
            else:
                return False
    
        return True
728x90