From 27af23f4d6cefb6bda02b479158c82fa6868d7ce Mon Sep 17 00:00:00 2001 From: sangge-rockpi <2251250136@qq.com> Date: Fri, 19 Jan 2024 22:18:07 +0800 Subject: [PATCH] update 9 --- leetcode/9.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/leetcode/9.py b/leetcode/9.py index a23e56e..40cbbbf 100644 --- a/leetcode/9.py +++ b/leetcode/9.py @@ -3,6 +3,8 @@ class Solution: def isPalindrome(self, x: int) -> bool: + if x < 0: + return False str_x = str(x) inv_str_x = str_x[::-1] int_inv_str_x = int(inv_str_x)