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 8006130 commit 706de57Copy full SHA for 706de57
Linked List/92. 反转链表 II.md
@@ -119,3 +119,30 @@ class Solution {
119
}
120
```
121
122
+Go语言:
123
+
124
+```go
125
+/**
126
+ * Definition for singly-linked list.
127
+ * type ListNode struct {
128
+ * Val int
129
+ * Next *ListNode
130
+ * }
131
+ */
132
+func reverseBetween(head *ListNode, left int, right int) *ListNode {
133
+ dummy := &ListNode{-1, head}
134
+ pre := dummy
135
+ for i := 0; i < left - 1; i++ {
136
+ pre = pre.Next
137
+ }
138
+ cur, next := pre.Next, pre.Next.Next
139
+ for i := 0; i < right - left; i++ {
140
+ cur.Next = next.Next
141
+ next.Next = pre.Next
142
+ pre.Next = next
143
+ next = cur.Next
144
145
+ return dummy.Next
146
+}
147
+```
148
0 commit comments