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 19f6205 commit 4bf599cCopy full SHA for 4bf599c
valid-palindrome/sj.java
@@ -0,0 +1,18 @@
1
+import java.util.*;
2
+class Solution {
3
+ public boolean isPalindrome(String s) {
4
+ String words = s.toLowerCase().replaceAll("[^0-9A-Za-z]","");
5
+ //System.out.println(words);
6
+ Deque<Character> stack = new ArrayDeque<>();
7
+ for(int i=0;i<words.length();i++){
8
+ stack.push(words.charAt(i));
9
+ }
10
+ while(!stack.isEmpty()){
11
12
+ if(words.charAt(i)==stack.pop()) continue;
13
+ else return false;
14
15
16
+ return true;
17
18
+}
0 commit comments