Skip to content

Commit e95d07a

Browse files
authored
Create Palindrome Numbers
1 parent 6761867 commit e95d07a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

Palindrome Numbers

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public boolean isPalindrome(int x) {
3+
int reverse = 0;
4+
int a = x;
5+
6+
while (x > 0) {
7+
if (x != 0) {
8+
reverse = (reverse * 10) + (x % 10);
9+
x = x / 10;
10+
}
11+
else {
12+
reverse = 0;
13+
}
14+
}
15+
16+
return reverse == a;
17+
18+
}
19+
}

0 commit comments

Comments
 (0)