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 aedda87 commit e037b87Copy full SHA for e037b87
problems/0206.翻转链表.md
@@ -164,6 +164,25 @@ class Solution {
164
}
165
```
166
167
+```java
168
+// 从后向前递归
169
+class Solution {
170
+ ListNode reverseList(ListNode head) {
171
+ // 边缘条件判断
172
+ if(head == null) return null;
173
+ if (head.next == null) return head;
174
+
175
+ // 递归调用,翻转第二个节点开始往后的链表
176
+ ListNode last = reverseList(head.next);
177
+ // 翻转头节点与第二个节点的指向
178
+ head.next.next = head;
179
+ // 此时的 head 节点为尾节点,next 需要指向 NULL
180
+ head.next = null;
181
+ return last;
182
+ }
183
+}
184
+```
185
186
Python迭代法:
187
```python
188
#双指针
0 commit comments