Skip to content

Commit d5b99ab

Browse files
authored
Add second solution for 9. Palindrome Number. (Tahanima#98)
1 parent 8633634 commit d5b99ab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution:
2+
def isPalindrome(self, x: int) -> bool:
3+
x_str = str(x)
4+
left_idx = 0
5+
right_idx = len(x_str) - 1
6+
7+
while left_idx < right_idx:
8+
if x_str[left_idx] != x_str[right_idx]:
9+
return False
10+
11+
left_idx += 1
12+
right_idx -= 1
13+
14+
return True

0 commit comments

Comments
 (0)