-
Notifications
You must be signed in to change notification settings - Fork 0
/
ispalindrome.java
50 lines (45 loc) · 986 Bytes
/
ispalindrome.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package leetcode;
public class ispalindrome {
public static boolean isPalindrome(int x) {
if(x<0) return false;
int count = 0, cp = x ,res = 0;
while(x!=0) {
res = res*10 + x%10;
x/=10;
}
if(res == cp) return true;
return false;
/*
for(int i=0, j=s.length()-1;i<j;) {
char ic = s.charAt(i);
char jc = s.charAt(j);
if(s.charAt(i)>='A'&&s.charAt(i)<='Z') {
ic += ' ';
}
if(s.charAt(j)>='A'&&s.charAt(j)<='Z') {
jc+=' ';
}
if(!(ic>='a'&&ic<='z'||ic>='0'&&ic<='9')) {
i++;
continue;
}
if(!(jc>='a'&&jc<='z'||jc>='0'&&jc<='9')) {
j--;
continue;
}
if(jc!=ic) {
System.out.println("false");
return false;
}
i++;
j--;
}
return true;*/
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int x = 12521;
boolean k = isPalindrome(x);
System.out.print(k);
}
}