mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-07 01:44:56 +08:00
add: leetcode 0014 test
This commit is contained in:
@ -0,0 +1,45 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question14 struct {
|
||||
para14
|
||||
ans14
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
type para14 struct {
|
||||
strs []string
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
type ans14 struct {
|
||||
ans string
|
||||
}
|
||||
|
||||
func Test_Problem14(t *testing.T) {
|
||||
|
||||
qs := []question14{
|
||||
|
||||
{
|
||||
para14{[]string{"flower", "flow", "flight"}},
|
||||
ans14{"fl"},
|
||||
},
|
||||
|
||||
{
|
||||
para14{[]string{"dog", "racecar", "car"}},
|
||||
ans14{""},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 14------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans14, q.para14
|
||||
fmt.Printf("【input】:%v 【output】:%v\n", p.strs, longestCommonPrefix(p.strs))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
Reference in New Issue
Block a user