public ListNode reverseBetween(ListNode head, int m, int n) {
    	if(m==n) return head;
    	
    	ListNode start = null; 
    	ListNode beforestart = null; 
    	ListNode curr = null; 
    	
    	for(int i=0; i<m-1; i++)
    	{
    		beforestart = beforestart==null?head:beforestart.next; 
    	}
    	
   		start = beforestart==null?head:beforestart.next;
   		ListNode end = start;
    	
   		curr = start.next; 
    	ListNode oldNext = curr.next;
    	for(int i=0; i<n-m; i++)
    	{	    		
    		oldNext = curr.next; 
    		curr.next = start; 
    		start = curr; 
    		curr = oldNext; 
    	}
    	end.next = oldNext;
    	
    	if(beforestart!= null)
    		beforestart.next = start;
  	    	
    	return (beforestart== null?start:head); 
    }