反转链表
ListNode* reverseList(ListNode* head) {
ListNode* tail=NULL;
ListNode* front=head;
ListNode* curr=NULL;
//先令curr指向front,front移动下一个,curr的next指向tail实现反转
//再移动tail
while(front!=NULL){
curr=front;
front=front->next;
curr->next=tail;
tail=curr;
}
return tail;
}

浙公网安备 33010602011771号