We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 640f4f0 commit fb31cbaCopy full SHA for fb31cba
Linked List/206. 反转链表.md
@@ -65,6 +65,32 @@ class Solution {
65
}
66
```
67
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
94
方法二,递归:
95
96
```java
0 commit comments