1-Find the node from where the sub-list to be reversed starts.

2-Find the next node where this sub-list to be reversed ends

3- reverse the sub-list in place

4- change the next node of the node in step 1

5- change the next node of the node in step 2

```
def reverseBetween(self, head, m, n):
"""
:type head: ListNode
:type m: int
:type n: int
:rtype: ListNode
"""
if not head:
return None
if not head.next:
return head
if m>=n:
return head
cur=head
i=1
prev=ListNode(-1)
prev.next=cur
while (cur and i<m): #O(m)
i+=1
prev=cur
cur=cur.next
print(prev.val)
last=cur
while(i<n): #O(m-n)
last=last.next
i+=1
next=last.next
temp1=None
ccur=cur
j=m
print(cur.val)
while(j<=n and cur): #O(n-m)
temp=cur.next
cur.next=temp1
temp1=cur
cur=temp
j+=1
prev.next=temp1
ccur.next=next
if m!=1:
return head
else:
return temp1
```