Skip to content

Commit 179ac20

Browse files
committed
add: leetcode 0014 test
1 parent 8583203 commit 179ac20

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package leetcode
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
)
7+
8+
type question14 struct {
9+
para14
10+
ans14
11+
}
12+
13+
// para 是参数
14+
type para14 struct {
15+
strs []string
16+
}
17+
18+
// ans 是答案
19+
type ans14 struct {
20+
ans string
21+
}
22+
23+
func Test_Problem14(t *testing.T) {
24+
25+
qs := []question14{
26+
27+
{
28+
para14{[]string{"flower", "flow", "flight"}},
29+
ans14{"fl"},
30+
},
31+
32+
{
33+
para14{[]string{"dog", "racecar", "car"}},
34+
ans14{""},
35+
},
36+
}
37+
38+
fmt.Printf("------------------------Leetcode Problem 14------------------------\n")
39+
40+
for _, q := range qs {
41+
_, p := q.ans14, q.para14
42+
fmt.Printf("【input】:%v 【output】:%v\n", p.strs, longestCommonPrefix(p.strs))
43+
}
44+
fmt.Printf("\n\n\n")
45+
}

0 commit comments

Comments
 (0)