public ListNode reverseBetween(ListNode head, int m, int n) {
        if(m == n)
            return head;
        Stack<ListNode> stack = new Stack<ListNode>();
        ListNode headNew = new ListNode(-1);
        ListNode step = headNew;
        ListNode index = head;
        ListNode left = null;

        for(int i=1;index != null && i <= n;i++){
            if(i<= n && i>=m){
                stack.add(index);
            }else{
                step.next = index;
                step = step.next;
            }
            index = index.next;
        }
        left = stack.peek().next;
        while(!stack.empty()){
            step.next = stack.pop();
            step = step.next;
        }
        step.next = left;
        return headNew.next;
    }