mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-06 01:15:57 +08:00
71 lines
1.0 KiB
Go
71 lines
1.0 KiB
Go
package leetcode
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/halfrost/LeetCode-Go/structures"
|
|
)
|
|
|
|
type question61 struct {
|
|
para61
|
|
ans61
|
|
}
|
|
|
|
// para 是参数
|
|
// one 代表第一个参数
|
|
type para61 struct {
|
|
one []int
|
|
k int
|
|
}
|
|
|
|
// ans 是答案
|
|
// one 代表第一个答案
|
|
type ans61 struct {
|
|
one []int
|
|
}
|
|
|
|
func Test_Problem61(t *testing.T) {
|
|
|
|
qs := []question61{
|
|
|
|
{
|
|
para61{[]int{1, 2, 3, 4, 5}, 2},
|
|
ans61{[]int{4, 5, 1, 2, 3}},
|
|
},
|
|
|
|
{
|
|
para61{[]int{1, 2, 3, 4, 5}, 3},
|
|
ans61{[]int{4, 5, 1, 2, 3}},
|
|
},
|
|
|
|
{
|
|
para61{[]int{0, 1, 2}, 4},
|
|
ans61{[]int{2, 0, 1}},
|
|
},
|
|
|
|
{
|
|
para61{[]int{1, 1, 1, 2}, 3},
|
|
ans61{[]int{1, 1, 2, 1}},
|
|
},
|
|
|
|
{
|
|
para61{[]int{1}, 10},
|
|
ans61{[]int{1}},
|
|
},
|
|
|
|
{
|
|
para61{[]int{}, 100},
|
|
ans61{[]int{}},
|
|
},
|
|
}
|
|
|
|
fmt.Printf("------------------------Leetcode Problem 61------------------------\n")
|
|
|
|
for _, q := range qs {
|
|
_, p := q.ans61, q.para61
|
|
fmt.Printf("【input】:%v 【output】:%v\n", p, structures.List2Ints(rotateRight(structures.Ints2List(p.one), p.k)))
|
|
}
|
|
fmt.Printf("\n\n\n")
|
|
}
|