- ListNode* reverseList(ListNode* head) {
- if(!head){
- return NULL;
- }
- ListNode *curr=head;
- ListNode*next= NULL;
- ListNode*pre = NULL;
- while(curr){
- next = curr->next;
- curr->next = pre;
- pre = curr;
- curr = next;
- }
- return pre;
- }
- //该片段来自于http://www.codesnippet.cn/detail/2906201512958.html
来源: http://www.codesnippet.cn/detail/2906201512958.html