We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cb1e50a commit 8c4b514Copy full SHA for 8c4b514
valid-palindrome-ii.go
@@ -0,0 +1,39 @@
1
+package leetcode_solutions_golang
2
+
3
+//https://leetcode.com/problems/valid-palindrome-ii/
4
+func validPalindrome(s string) bool {
5
+ left := 0
6
+ right := len(s) - 1
7
+ counter := 0
8
+ for left <= right {
9
+ if counter > 1 {
10
+ break
11
+ }
12
+ if s[left] != s[right] {
13
+ counter++
14
+ right--
15
+ } else {
16
+ left++
17
18
19
20
+ if counter < 2 {
21
+ return true
22
23
+ left = 0
24
+ right = len(s) - 1
25
+ counter = 0
26
27
28
+ return false
29
30
31
32
33
34
35
36
37
38
39
+}
0 commit comments