mirror of
https://github.com/chefyuan/algorithm-base.git
synced 2025-08-03 14:32:07 +00:00
验证,校对
This commit is contained in:
@@ -4,14 +4,12 @@
|
||||
>
|
||||
> 另外希望手机阅读的同学可以来我的 <u>[**公众号:袁厨的算法小屋**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u> 两个平台同步,想要和题友一起刷题,互相监督的同学,可以在我的小屋点击<u>[**刷题小队**](https://raw.githubusercontent.com/tan45du/test/master/微信图片_20210320152235.2pthdebvh1c0.png)</u>进入。
|
||||
|
||||
今天我们来说一下反转链表 2,其实这个和 1 的思路差不多,今天先说一个比较好理解的方法,完全按照反转链表 1 的方法来解决,大家看这个题目之前要先看一下[【动画模拟】leetcode 206 反转链表](https://github.com/chefyuan/algorithm-base/blob/main/animation-simulation/%E9%93%BE%E8%A1%A8%E7%AF%87/leetcode206%E5%8F%8D%E8%BD%AC%E9%93%BE%E8%A1%A8.md)
|
||||
今天我们来说一下反转链表 2,其实这个和 1 的思路差不多,今天先说一个比较好理解的方法,完全按照反转链表 1 的方法来解决,大家看这个题目之前要先看一下[【动画模拟】leetcode 206 反转链表](https://github.com/chefyuan/algorithm-base/blob/main/animation-simulation/%E9%93%BE%E8%A1%A8%E7%AF%87/leetcode206%E5%8F%8D%E8%BD%AC%E9%93%BE%E8%A1%A8.md)。
|
||||
|
||||
下面我们先来看一下题目。
|
||||
|
||||
#### [92. 反转链表 II](https://leetcode-cn.com/problems/reverse-linked-list-ii/)
|
||||
|
||||
难度中等836
|
||||
|
||||
给你单链表的头指针 `head` 和两个整数 `left` 和 `right` ,其中 `left <= right` 。请你反转从位置 `left` 到位置 `right` 的链表节点,返回 **反转后的链表** 。
|
||||
|
||||
**示例 1:**
|
||||
@@ -166,7 +164,6 @@ var reverseBetween = function(head, left, right) {
|
||||
return temp.next;
|
||||
};
|
||||
|
||||
|
||||
//和反转链表1代码一致
|
||||
var reverse = function(head) {
|
||||
let low = null;
|
||||
@@ -183,7 +180,7 @@ var reverse = function(head) {
|
||||
|
||||
Python Code:
|
||||
|
||||
```py
|
||||
```python
|
||||
class Solution:
|
||||
def reverseBetween(self, head: ListNode, left: int, right: int) -> ListNode:
|
||||
# 虚拟头节点
|
||||
|
Reference in New Issue
Block a user