Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f4d233a

Browse files
committed
update: 206
1 parent 377116d commit f4d233a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

‎problems/0206.reverse-linked-list/run.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
package list
22

3-
type ListNode struct {
4-
Val int
5-
Next *ListNode
6-
}
7-
8-
func reverseList(head *ListNode) *ListNode {
3+
import "github.com/itcuihao/leetcode-go/structure"
94

10-
p:=&ListNode{}
5+
funcreverseList(head*structure.ListNode) *structure.ListNode {
116

7+
var p *structure.ListNode
128
for head != nil {
139
temp := head.Next
1410
head.Next = p

‎problems/0206.reverse-linked-list/run_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package list
22

3-
import "testing"
3+
import (
4+
"testing"
5+
6+
"github.com/itcuihao/leetcode-go/structure"
7+
)
48

59
func TestRun(t *testing.T) {
6-
l := &ListNode{
10+
l := &structure.ListNode{
711
Val: 1,
8-
Next: &ListNode{
12+
Next: &structure.ListNode{
913
Val: 2,
10-
Next: &ListNode{
14+
Next: &structure.ListNode{
1115
Val: 3,
1216
},
1317
},
1418
}
1519

1620
lr := reverseList(l)
17-
for lr.Next != nil {
21+
for lr != nil {
1822
t.Log(lr.Val)
1923
lr = lr.Next
2024
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /