I am trying to use to stack to add the nodes to be reversed. And then pop it and link the pointers before m and after n.

```
public class Solution {
public ListNode reverseBetween(ListNode head, int m, int n) {
if(head==null) return head;
ListNode current= head;
int i=0;
Stack<ListNode> reverse = new Stack<>();
while(i<m-1)
{
if(current.next==null) return head;
current=current.next;
i++;
}
ListNode temp= current;
while(i<n)
{
if(temp==null)return head;
reverse.push(temp);
temp=temp.next;
i++;
}
System.out.println(temp.val);
while(!reverse.empty())
{
//System.out.println(current.next.val);
ListNode t=reverse.pop();
//System.out.println(t.val);
current.next=t;
current=current.next;
}
current.next=temp;
return head;
}
```

}