Reverse a linked list from position m to n. Do it in one-pass.
Note: 1 ≤ m ≤ n ≤ length of list.
Example:
Input: 1->2->3->4->5->NULL, m = 2, n = 4
Output: 1->4->3->2->5->NULL
class Solution:
     def reverseBetween(self, head, m, n):
         """
         :type head: ListNode
         :type m: int
         :type n: int
         :rtype: ListNode
         """
         dummy = ListNode(-1)
         dummy.next = head
         count = 0
         pre = dummy
 
         while head:
             count +=1
             temp = head.next
             if count == m:
                 mNode = head
             if count < m:
                 pre = pre.next
             if count > m and count <= n:
                 head.next = pre.next
                 pre.next = head
                 mNode.next = temp
             head = temp
         return dummy.next
class Solution:
     def reverseBetween(self, head, m, n):
         """
         :type head: ListNode
         :type m: int
         :type n: int
         :rtype: ListNode
         """
         dummy = ListNode(-1)
         dummy.next = head
         count = 0
         pre = dummy
 
         while head:
             count +=1
             temp = head.next
             if count == m:
                 mNode = head
             if count < m:
                 pre = pre.next
             if count > m and count <= n:
                 head.next = pre.next
                 pre.next = head
                 mNode.next = temp
             head = temp
         return dummy.next