Skip to content

Commit 787aeff

Browse files
aQuaaQua
aQua
authored and
aQua
committed
61 accepted, 9ms
1 parent 2dcec46 commit 787aeff

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

Algorithms/0061.rotate-list/rotate-list.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ type ListNode struct {
77
}
88

99
func rotateRight(head *ListNode, k int) *ListNode {
10+
if k == 0 || head == nil {
11+
return head
12+
}
13+
1014
end := head
1115
// size 是 List 的长度
1216
size := 1

Algorithms/0061.rotate-list/rotate-list_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ func Test_Problem0061(t *testing.T) {
2727
ast := assert.New(t)
2828

2929
qs := []question{
30+
question{
31+
para{
32+
[]int{},
33+
1,
34+
},
35+
ans{
36+
[]int{},
37+
},
38+
},
3039

3140
question{
3241
para{

0 commit comments

Comments
 (0)