We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d873d96 commit 1b3adb8Copy full SHA for 1b3adb8
Valid Palindrome
@@ -0,0 +1,25 @@
1
+class Solution {
2
+ public boolean isPalindrome(String s) {
3
+ String line = "";
4
+ String reverse = "";
5
+ for(int i = 0; i<s.length(); i++){
6
+ if((s.charAt(i) >= 'A' && s.charAt(i)<='Z') || (s.charAt(i) >= 'a' && s.charAt(i)<='z') ||(s.charAt(i)>='0' && s.charAt(i)<='9')){
7
+ line += s.charAt(i)+"";
8
+ }
9
10
+ line = line.toLowerCase();
11
+ //System.out.println(line);
12
+ return reverse(line).equals(line);
13
14
+
15
+ public static String reverse(String a){
16
+ String result = "";
17
+ for(int i = a.length()-1; i>=0; i--){
18
+ result += a.charAt(i);
19
20
21
+ return result;
22
23
24
25
+}
0 commit comments