Hi, this is Shunchi!

  • Home

  • Tags0

  • Archives267

  • Categories0

  • Curricula

  • DSA

  • LeetCode_Notes

  • Interviews

  • General

  • Resume

9. Palindrome Number

Posted on 2020-06-13 | Edited on 2021-01-22

LeetCode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
class Solution {
private long reverse(int x){
long i=0;
while(x!=0){
i=i*10+x%10;
x/=10;
}
return i;
}
public boolean isPalindrome(int x) {
if(x<0) return false;
return reverse(x)>Integer.MAX_VALUE?false:x==(int)reverse(x);
}
}
<1…163164165…267>
ShunchiZhou

ShunchiZhou

267 posts
RSS
GitHub E-Mail Gitbook Linkedin
© 2024 ShunchiZhou
Powered by Hexo v5.4.0
|
0%