7 lines 0ms C recursive solution

  • 0
    struct ListNode* reverseList(struct ListNode* head) {
        if (!head) return NULL;
        if (!head->next) return head;
        ListNode *result = reverseList(head->next);
        head->next->next = head;
        head->next = NULL;
        return result;

  • 0

    smart, helpful, thanks

Log in to reply

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