Skip to content

Commit fb31cba

Browse files
Update 206. 反转链表.md
1 parent 640f4f0 commit fb31cba

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Linked List/206. 反转链表.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ class Solution {
6565
}
6666
```
6767

68+
Go语言:
69+
70+
```go
71+
/**
72+
* Definition for singly-linked list.
73+
* type ListNode struct {
74+
* Val int
75+
* Next *ListNode
76+
* }
77+
*/
78+
func reverseList(head *ListNode) *ListNode {
79+
var pre *ListNode
80+
for head != nil {
81+
next := head.Next
82+
head.Next = pre
83+
pre = head
84+
head = next
85+
}
86+
return pre
87+
}
88+
```
89+
90+
91+
92+
93+
6894
方法二,递归:
6995

7096
```java

0 commit comments

Comments
 (0)