Medium

## Question

Reverse a linked list from position m to n.

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

Example
Given 1->2->3->4->5->NULL , m = 2 and n = 4 , return 1->4->3->2->5->NULL .

## Challenge

Reverse it in-place and in one-pass

## Thinking

Did question Reverse Linked List before. Tried to use reverse2 solution but it confused me. So reverse1 is the best one for me.
Just need skip m nodes and start to reverse element till position n.

## Solution

#### Java

``````/**
* Definition for ListNode
* public class ListNode {
*     int val;
*     ListNode next;
*     ListNode(int x) {
*         val = x;
*         next = null;
*     }
* }
*/
public class Solution {
/**
* @oaram m and n
* @return: The head of the reversed ListNode
*/
public ListNode reverseBetween(ListNode head, int m , int n) {
if (head == null || head.next == null || n <= m) {
}
ListNode dummy = new ListNode(-1);
ListNode prev = dummy;
int index = 1;
while (index < m && prev != null) {
prev = prev.next;
++index;
}
if (index < m || prev == null) {