class Solution { public ListNode reverseBetween(ListNode head, int m, int n) { if(m == 1) { ListNode node = reverse(head,n); return node; } head.next = reverseBetween(head.next,m-1,n-1); return head; } ListNode last = null; public ListNode reverse(ListNode head, int k) { if(k == 1) { last = head.next; return head; } ListNode node = reverse(head.next,k-1); head.next.next = head; head.next = last; return node; } }