1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 11:21:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part6

This commit is contained in:
2022-03-27 20:56:26 +08:00
parent c11d601602
commit 08d1f2a596
1096 changed files with 88216 additions and 2 deletions

View File

@@ -0,0 +1,31 @@
给你单链表的头指针 <code>head</code> 和两个整数 <code>left</code><code>right</code> ,其中 <code>left <= right</code> 。请你反转从位置 <code>left</code> 到位置 <code>right</code> 的链表节点,返回 <strong>反转后的链表</strong>
<p> </p>
<p><strong>示例 1</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2021/02/19/rev2ex2.jpg" style="width: 542px; height: 222px;" />
<pre>
<strong>输入:</strong>head = [1,2,3,4,5], left = 2, right = 4
<strong>输出:</strong>[1,4,3,2,5]
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>head = [5], left = 1, right = 1
<strong>输出:</strong>[5]
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li>链表中节点数目为 <code>n</code></li>
<li><code>1 <= n <= 500</code></li>
<li><code>-500 <= Node.val <= 500</code></li>
<li><code>1 <= left <= right <= n</code></li>
</ul>
<p> </p>
<p><strong>进阶:</strong> 你可以使用一趟扫描完成反转吗?</p>