// Reverse a linked list from position m to n. Do it in-place and in one-pass.

// For example:
// Given 1->2->3->4->5->NULL, m = 2 and n = 4,

// return 1->4->3->2->5->NULL.

// Note:
// Given m, n satisfy the following condition:
// 1 ≤ m ≤ n ≤ length of list.

/**
 * Definition for singly-linked list.
 * public class ListNode {
 *     int val;
 *     ListNode next;
 *     ListNode(int x) {
 *         val = x;
 *         next = null;
 *     }
 * }
 */
public class Solution {
    public ListNode reverseBetween(ListNode head, int m, int n) {
        
    }
}
@@ -544,17 +544,859 @@
 n) %7B
+%09
 %0A    
-    
+%09if(head == null %7C%7C head.next == null %7C%7C m == n) return head;%0A    %09ListNode dummy = new ListNode(0);%0A    %09dummy.next = head;%0A    %09ListNode runner = dummy;%0A%0A    %09for(int i = 0; i %3C m - 1; i++)%7B%0A    %09%09runner = runner.next;%0A    %09%09if(runner == null) return dummy.next;%0A    %09%7D%0A%0A    %09ListNode start = runner.next;%0A    %09ListNode end = start;%0A    %09for(int i = 0; i %3C (n - m); i++)%7B%0A    %09%09end = end.next;%0A    %09%09if(end == null) return dummy.next;%0A    %09%7D%0A%0A    %09runner.next = reverse(start, end);%0A    %09return dummy.next;%0A    %7D%0A%0A    public ListNode reverse(ListNode start, ListNode end)%7B%0A    %09ListNode finalEnd = end.next;%0A    %09ListNode pre = start;%0A    %09ListNode curr = start.next;%0A%0A    %09while(curr != finalEnd)%7B%0A    %09%09ListNode next = curr.next;%0A    %09%09curr.next = pre;%0A    %09%09pre = curr;%0A    %09%09curr = next;%0A    %09%7D%0A    %09start.next = finalEnd;%0A    %09return end;
 %0A   

update reverse linked lists ii solution