Skip to content

Commit 4dc53e5

Browse files
committed
Time: 71 ms (14.79%) | Memory: 16.6 MB (56.92%) - LeetSync
1 parent ec74b44 commit 4dc53e5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
class Solution:
22
def isPalindrome(self, x: int) -> bool:
3-
y = str(x)
4-
return y == y[::-1]
3+
# y = str(x)
4+
# return y == y[::-1]
5+
6+
# follow up without converting
7+
if x < 0: return False
8+
div = 1
9+
while x >= 10 * div:
10+
div*=10
11+
12+
while x:
13+
if x // div != x % 10: return False
14+
x = (x%div) // 10
15+
div /= 100
16+
return True

0 commit comments

Comments
 (0)