# 反转链表 II

给你单链表的头指针 <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://img-service.csdnimg.cn/img_convert/c664df96e99b9097662307d2e0368322.jpeg" style="width: 542px; height: 222px;" /><pre><strong>输入：</strong>head = [1,2,3,4,5], left = 2, right = 4<strong><br />输出：</strong>[1,4,3,2,5]</pre><p><strong>示例 2：</strong></p><pre><strong>输入：</strong>head = [5], left = 1, right = 1<strong><br />输出：</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>

## template

```java
class Solution {
	public ListNode reverseBetween(ListNode head, int m, int n) {
		ListNode dummy = new ListNode(0);
		dummy.next = head;
		ListNode pre = dummy;
		for (int i = 1; i < m; i++) {
			pre = pre.next;
		}
		head = pre.next;
		for (int i = m; i < n; i++) {
			ListNode nex = head.next;
			head.next = nex.next;
			nex.next = pre.next;
			pre.next = nex;
		}
		return dummy.next;
	}
}
```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```