Simple C solution - 0ms, iterative


  • 0
    Y
    struct ListNode* reverseList(struct ListNode* head) {
        struct ListNode *tail=head, *new_head=NULL;
        while(tail){
            head = tail;
            tail = tail->next;
            head->next = new_head;
            new_head = head;
        }
        return new_head;
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.