1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ListNode* ReverseList(ListNode* pHead) { if(pHead==nullptr) return pHead; ListNode* pre=nullptr,*mid=pHead,*last=nullptr; while(mid->next!=nullptr){ last=mid->next; mid->next=pre; pre=mid;mid=last; } mid->next=pre; pHead=mid; return pHead; }
|