File tree 3 files changed +64
-0
lines changed
solution/0100-0199/0125.Valid Palindrome
3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,29 @@ private:
103
103
};
104
104
```
105
105
106
+ ### **tTypeScript**
107
+
108
+ ```ts
109
+ function isPalindrome(s: string): boolean {
110
+ let left: number = 0, right: number = s.length - 1;
111
+ while (left < right) {
112
+ let char1: string = s.charAt(left);
113
+ let char2: string = s.charAt(right);
114
+ if (!(/[a-zA-Z0-9]/).test(char1)) {
115
+ ++left;
116
+ } else if (!(/[a-zA-Z0-9]/).test(char2)) {
117
+ --right;
118
+ } else if (char1.toLocaleLowerCase() != char2.toLocaleLowerCase()) {
119
+ return false;
120
+ } else {
121
+ ++left;
122
+ --right;
123
+ }
124
+ }
125
+ return true;
126
+ };
127
+ ```
128
+
106
129
### ** ...**
107
130
108
131
```
Original file line number Diff line number Diff line change @@ -106,6 +106,29 @@ private:
106
106
};
107
107
```
108
108
109
+ ### **TypeScript**
110
+
111
+ ```ts
112
+ function isPalindrome(s: string): boolean {
113
+ let left: number = 0, right: number = s.length - 1;
114
+ while (left < right) {
115
+ let char1: string = s.charAt(left);
116
+ let char2: string = s.charAt(right);
117
+ if (!(/[a-zA-Z0-9]/).test(char1)) {
118
+ ++left;
119
+ } else if (!(/[a-zA-Z0-9]/).test(char2)) {
120
+ --right;
121
+ } else if (char1.toLocaleLowerCase() != char2.toLocaleLowerCase()) {
122
+ return false;
123
+ } else {
124
+ ++left;
125
+ --right;
126
+ }
127
+ }
128
+ return true;
129
+ };
130
+ ```
131
+
109
132
### ** ...**
110
133
111
134
```
Original file line number Diff line number Diff line change
1
+ function isPalindrome ( s : string ) : boolean {
2
+ let left : number = 0 , right : number = s . length - 1 ;
3
+ while ( left < right ) {
4
+ let char1 : string = s . charAt ( left ) ;
5
+ let char2 : string = s . charAt ( right ) ;
6
+ if ( ! ( / [ a - z A - Z 0 - 9 ] / ) . test ( char1 ) ) {
7
+ ++ left ;
8
+ } else if ( ! ( / [ a - z A - Z 0 - 9 ] / ) . test ( char2 ) ) {
9
+ -- right ;
10
+ } else if ( char1 . toLocaleLowerCase ( ) != char2 . toLocaleLowerCase ( ) ) {
11
+ return false ;
12
+ } else {
13
+ ++ left ;
14
+ -- right ;
15
+ }
16
+ }
17
+ return true ;
18
+ } ;
You can’t perform that action at this time.
0 commit comments