forked from halfrost/LeetCode-Go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15. 3Sum_test.go
59 lines (47 loc) · 1.32 KB
/
15. 3Sum_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package leetcode
import (
"fmt"
"testing"
)
type question15 struct {
para15
ans15
}
// para 是参数
// one 代表第一个参数
type para15 struct {
a []int
}
// ans 是答案
// one 代表第一个答案
type ans15 struct {
one [][]int
}
func Test_Problem15(t *testing.T) {
qs := []question15{
{
para15{[]int{0, 0, 0}},
ans15{[][]int{{0, 0, 0}}},
},
{
para15{[]int{-1, 0, 1, 2, -1, -4}},
ans15{[][]int{{-1, 0, 1}, {-1, -1, 2}}},
},
{
para15{[]int{-4, -2, -2, -2, 0, 1, 2, 2, 2, 3, 3, 4, 4, 6, 6}},
ans15{[][]int{{-4, -2, 6}, {-4, 0, 4}, {-4, 1, 3}, {-4, 2, 2}, {-2, -2, 4}, {-2, 0, 2}}},
},
{
para15{[]int{5, -7, 3, -3, 5, -10, 4, 8, -3, -8, -3, -3, -1, -8, 6, 4, -4, 7, 2, -5, -2, -7, -3, 7, 2, 4, -6, 5}},
ans15{[][]int{{-10, 2, 8}, {-10, 3, 7}, {-10, 4, 6}, {-10, 5, 5}, {-8, 2, 6}, {-8, 3, 5}, {-8, 4, 4}, {-7, -1, 8},
{-7, 2, 5}, {-7, 3, 4}, {-6, -2, 8}, {-6, -1, 7}, {-6, 2, 4}, {-5, -3, 8}, {-5, -2, 7}, {-5, -1, 6}, {-5, 2, 3},
{-4, -3, 7}, {-4, -2, 6}, {-4, -1, 5}, {-4, 2, 2}, {-3, -3, 6}, {-3, -2, 5}, {-3, -1, 4}, {-2, -1, 3}}},
},
}
fmt.Printf("------------------------Leetcode Problem 15------------------------\n")
for _, q := range qs {
_, p := q.ans15, q.para15
fmt.Printf("【input】:%v 【output】:%v\n", p, threeSum(p.a))
}
fmt.Printf("\n\n\n")
}