-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_125.java
More file actions
30 lines (28 loc) · 943 Bytes
/
Copy path_125.java
File metadata and controls
30 lines (28 loc) · 943 Bytes
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
public class _125 {
public static boolean isPalindrome(String s) {
if (s == " ") {
return true;
}
s = s.toLowerCase();
String snew = "";
String snew2 = "";
System.out.println(s);
for (int i = s.length() - 1, j = 0; i >= 0; i--, j++) {
if ((s.charAt(i) >= 'a' && s.charAt(i) <= 'z') || (s.charAt(i) > '0' && s.charAt(i) <= '9')) {
snew += s.charAt(i);
}
if ((s.charAt(j) >= 'a' && s.charAt(j) <= 'z') || (s.charAt(j) >= '0' && s.charAt(j) <= '9')) {
snew2 += s.charAt(j);
}
}
System.out.println(snew.toString());
System.out.println(snew2.toString());
if (snew.equals(snew2)) {
return true;
} else
return false;
}
public static void main(String[] args) {
System.out.println(isPalindrome("0z;z ; 0"));
}
}