classSolution { public: /** * @param head: ListNode head is the head of the linked list * @param m: An integer * @param n: An integer * @return: The head of the reversed ListNode */ ListNode * reverseBetween(ListNode * head, int m, int n){ // write your code here ListNode * p1,*psre,*pere,*ps,*pe,*penext; if(m==n)return head; p1=head; pe=ps=p1; if(p1->next!=NULL) for(int i=1;p1!=NULL;i++,p1=p1->next){ if(i==m){ ps=p1; } if(i==n){ pe=p1; } if(i<m){ psre=p1; } if(i<n){ pere=p1; } } // if(p1->next!=NULL) penext=pe->next; if(m!=1) psre->next=pe; else{ head=pe; } ListNode *tp,*tpnext,*temp; tp=ps; if(head->next!=NULL){ tpnext=ps->next; ps->next=penext; } if(n-m!=0){