From 4985021976d7c0b3169fb9b865085adb18bb2844 Mon Sep 17 00:00:00 2001 From: sangge-rockpi <2251250136@qq.com> Date: Fri, 19 Jan 2024 22:16:14 +0800 Subject: [PATCH] add leetcode 9 --- leetcode/9.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 leetcode/9.py diff --git a/leetcode/9.py b/leetcode/9.py new file mode 100644 index 0000000..a23e56e --- /dev/null +++ b/leetcode/9.py @@ -0,0 +1,9 @@ +# Given an integer, return true if x is a palindrome + + +class Solution: + def isPalindrome(self, x: int) -> bool: + str_x = str(x) + inv_str_x = str_x[::-1] + int_inv_str_x = int(inv_str_x) + return x == int_inv_str_x