I couldn't think of any simpler solution than this:


#1

I didn’t try to look at the editorial solution beforehand. Neither do I think I could come up with this intuitively. But here’s my recursive approach which in my opinion simplest to understand:

ListNode *revList(ListNode *prev, ListNode *curr){
    ListNode *nextNode;
    while(curr!=NULL){
        nextNode=curr->next;
        curr->next=prev;
        return revList(curr, nextNode);
    }
    return prev;
}

ListNode* Solution::reverseList(ListNode* A) {
    if(A==NULL || A->next==NULL) return A;
    return revList(NULL, A);
}

Let me know if you have trouble understanding this.