mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-13 15:34:00 +08:00
Add solution 560、1763、2164、2165、2166、2167、2169、2170、2171、2180、2181、2182、2183、
This commit is contained in:
@ -0,0 +1,63 @@
|
||||
package leetcode
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
type question560 struct {
|
||||
para560
|
||||
ans560
|
||||
}
|
||||
|
||||
// para 是参数
|
||||
// one 代表第一个参数
|
||||
type para560 struct {
|
||||
nums []int
|
||||
k int
|
||||
}
|
||||
|
||||
// ans 是答案
|
||||
// one 代表第一个答案
|
||||
type ans560 struct {
|
||||
one int
|
||||
}
|
||||
|
||||
func Test_Problem560(t *testing.T) {
|
||||
|
||||
qs := []question560{
|
||||
|
||||
{
|
||||
para560{[]int{1, 1, 1}, 2},
|
||||
ans560{2},
|
||||
},
|
||||
|
||||
{
|
||||
para560{[]int{1, 2, 3}, 3},
|
||||
ans560{2},
|
||||
},
|
||||
|
||||
{
|
||||
para560{[]int{1}, 0},
|
||||
ans560{0},
|
||||
},
|
||||
|
||||
{
|
||||
para560{[]int{-1, -1, 1}, 0},
|
||||
ans560{1},
|
||||
},
|
||||
|
||||
{
|
||||
para560{[]int{1, -1, 0}, 0},
|
||||
ans560{3},
|
||||
},
|
||||
}
|
||||
|
||||
fmt.Printf("------------------------Leetcode Problem 560------------------------\n")
|
||||
|
||||
for _, q := range qs {
|
||||
_, p := q.ans560, q.para560
|
||||
fmt.Printf("【input】:%v 【output】:%v\n", p, subarraySum(p.nums, p.k))
|
||||
}
|
||||
fmt.Printf("\n\n\n")
|
||||
}
|
Reference in New Issue
Block a user