###### leetcode Reverse Linked List II

/**
* public class ListNode {
*     int val;
*     ListNode next;
*     ListNode(int x) { val = x; }
* }
*/
public class Solution {
public ListNode reverseBetween(ListNode head, int m, int n) {
{
}
for(int i=1;i<m-1;i++)
{
front=front.next;
}

ListNode current=null;
ListNode nextNode=null;

ListNode workTail=null;

if(m!=1)
{
current=front.next;
nextNode=current.next;
current.next=null;
workTail=current;
}
else
{
}

for(int i=1;i<n-m+1;i++)
{
current=nextNode;
nextNode=current.next;
}
workTail.next=nextNode;
if(m!=1)
{
}
if(m==1)
{
}

}
}

ListNode* reverseBetween(ListNode *head, int m, int n) {
ListNode dummy(0), *prev = &dummy;
for (int i=1; i<m; i++)
prev = prev->next;
ListNode *pivot = prev->next;
for (int i=m; i<n; i++) {
swap(prev->next, pivot->next->next);
swap(prev->next, pivot->next);
}
return dummy.next;
}

#### 【LeetCode】Reverse Linked List II 解题报告

2014-12-05 15:59:28

#### leetcode：92. Reverse Linked List II（Java）解答

2015-12-26 16:14:34

#### 【LeetCode】92. Reverse Linked List II 解题报告

2017-03-28 09:42:23

2014-01-28 01:06:19

#### Reverse Linked List II -- LeetCode

2014-04-28 04:58:33

2014-01-28 11:06:09

#### leetcode 206: Reverse Linked List

2015-05-14 06:47:30

2016-02-19 13:39:20

#### 206. Reverse Linked List [easy] (Python)

2016-05-03 17:12:10

2015-08-06 07:40:14