Reverse List

less than 1 minute read

Just show the code

img Those explain is clearly

And Cpp code

ListNode* reverseList(ListNode* head) {
    ListNode* pre=NULL;
    ListNode* next=NULL;
    while(head!=NULL){
        next=head->next;
        head->next=pre;
        pre=head;
        head=next;
    }
    return pre;
}
Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.