Skip to content

Commit c2c6470

Browse files
committed
feat: adds palindrome_number exercise
1 parent 3d4fa03 commit c2c6470

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

palindrome_number.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def isPalindrome(self, x: int) -> bool:
3+
if x < 0:
4+
return False
5+
6+
num = x
7+
reversed_num = 0
8+
9+
for i in range(len(x)):
10+
reversed_num = reversed_num * 10 + x % 10
11+
x = x // 10
12+
13+
return num == reversed_num

0 commit comments

Comments
 (0)