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 d9d562f commit e8b4f8dCopy full SHA for e8b4f8d
javascript/125-ValidPalindrome.js
@@ -0,0 +1,30 @@
1
+class isValidPalindrome {
2
+ constructor(string){
3
+ this.string=string;
4
+ }
5
+ isPalindrome(string){
6
+ let left =0;
7
+ let right=string.length-1;
8
+ while(left<right){
9
+ while(left<right && this.isAlphaNumeric(string[left])){
10
+ left++
11
12
+ while(right>left && this.isAlphaNumeric(string[right])){
13
+ right--
14
15
+ if(string[left].toLowerCase()!=string[right].toLowerCase()) {
16
+ return false;
17
18
19
20
21
+ return true
22
23
+
24
+ isAlphaNumeric(c){
25
+ return ('A'.charCodeAt(0) <= c.charCodeAt(0) <='Z'.charCodeAt(0) ||
26
+ 'a'.charCodeAt(0) <= c.charCodeAt(0) <='z'.charCodeAt(0) ||
27
+ '0'.charCodeAt(0) <= c.charCodeAt(0) <='9'.charCodeAt(0))
28
29
30
+}
0 commit comments