Can anyone help me why I am getting the wrong answer?


  • 0
    M

    if(!head){
    return NULL;
    }
    struct ListNode *p=head->next;
    struct ListNode *tail = NULL;
    while(p){
    head->next = p->next;
    p->next = tail;
    tail = p;
    p = head->next;
    }

    head->next = tail;
    return head;

Log in to reply
 

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