Skip to content

Commit 96b6562

Browse files
aQuaaQua
aQua
authored and
aQua
committed
125 added
1 parent e44a469 commit 96b6562

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# [125. Valid Palindrome](https://leetcode.com/problems/valid-palindrome/)
2+
3+
## 题目
4+
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
5+
6+
For example,
7+
```
8+
"A man, a plan, a canal: Panama" is a palindrome.
9+
"race a car" is not a palindrome.
10+
```
11+
Note:
12+
Have you consider that the string might be empty? This is a good question to ask during an interview.
13+
14+
For the purpose of this problem, we define empty string as valid palindrome.
15+
16+
## 解题思路
17+
palindrome: 回文(指顺读和倒读都一样的词语)
18+
19+
见程序注释
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package Problem0125
2+
3+
func isPalindrome(s string) bool {
4+
5+
return true
6+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package Problem0125
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func Test_Problem0125(t *testing.T) {
11+
ast := assert.New(t)
12+
13+
// tcs is testcase slice
14+
tcs := []struct {
15+
s string
16+
ans bool
17+
}{
18+
19+
{
20+
"race a car",
21+
false,
22+
},
23+
24+
{
25+
"A man, a plan, a canal: Panama",
26+
true,
27+
},
28+
29+
// 可以多个 testcase
30+
}
31+
32+
for _, tc := range tcs {
33+
fmt.Printf("~~%v~~\n", tc)
34+
35+
ast.Equal(tc.ans, isPalindrome(tc.s), "输入:%v", tc)
36+
}
37+
}

0 commit comments

Comments
 (0)