File tree Expand file tree Collapse file tree 3 files changed +82
-0
lines changed
solution/0100-0199/0125.Valid Palindrome Expand file tree Collapse file tree 3 files changed +82
-0
lines changed Original file line number Diff line number Diff line change @@ -279,6 +279,35 @@ impl Solution {
279
279
}
280
280
```
281
281
282
+ ### ** Go**
283
+
284
+ ``` go
285
+ func isPalindrome (s string ) bool {
286
+ s = strings.ToLower (s)
287
+ left , right := 0 , len (s) - 1
288
+ for left < right {
289
+ for left < right && !verify (s[left]) {
290
+ left++
291
+ }
292
+ for left < right && !verify (s[right]) {
293
+ right--
294
+ }
295
+ if left < right {
296
+ if s[left] != s[right] {
297
+ return false
298
+ }
299
+ left++
300
+ right--
301
+ }
302
+ }
303
+ return true
304
+ }
305
+
306
+ func verify (ch byte ) bool {
307
+ return (ch >= ' A' && ch <= ' Z' ) || (ch >= ' a' && ch <= ' z' ) || (ch >= ' 0' && ch <= ' 9' )
308
+ }
309
+ ```
310
+
282
311
### ** ...**
283
312
284
313
```
Original file line number Diff line number Diff line change @@ -267,6 +267,35 @@ impl Solution {
267
267
}
268
268
```
269
269
270
+ ### ** Go**
271
+
272
+ ``` go
273
+ func isPalindrome (s string ) bool {
274
+ s = strings.ToLower (s)
275
+ left , right := 0 , len (s) - 1
276
+ for left < right {
277
+ for left < right && !verify (s[left]) {
278
+ left++
279
+ }
280
+ for left < right && !verify (s[right]) {
281
+ right--
282
+ }
283
+ if left < right {
284
+ if s[left] != s[right] {
285
+ return false
286
+ }
287
+ left++
288
+ right--
289
+ }
290
+ }
291
+ return true
292
+ }
293
+
294
+ func verify (ch byte ) bool {
295
+ return (ch >= ' A' && ch <= ' Z' ) || (ch >= ' a' && ch <= ' z' ) || (ch >= ' 0' && ch <= ' 9' )
296
+ }
297
+ ```
298
+
270
299
### ** ...**
271
300
272
301
```
Original file line number Diff line number Diff line change
1
+ func isPalindrome (s string ) bool {
2
+ s = strings .ToLower (s )
3
+ left , right := 0 , len (s ) - 1
4
+ for left < right {
5
+ for left < right && ! verify (s [left ]) {
6
+ left ++
7
+ }
8
+ for left < right && ! verify (s [right ]) {
9
+ right --
10
+ }
11
+ if left < right {
12
+ if s [left ] != s [right ] {
13
+ return false
14
+ }
15
+ left ++
16
+ right --
17
+ }
18
+ }
19
+ return true
20
+ }
21
+
22
+ func verify (ch byte ) bool {
23
+ return (ch >= 'A' && ch <= 'Z' ) || (ch >= 'a' && ch <= 'z' ) || (ch >= '0' && ch <= '9' )
24
+ }
You can’t perform that action at this time.
0 commit comments