Simple C++ recursive solution of 4 lines
int ct = 0;
    ListNode* removeNthFromEnd(ListNode* head, int n) {
        if(head == NULL) return NULL;
        head->next = removeNthFromEnd(head->next, n);
        ct++;
        return (ct == n ? head->next : head); 
    }
Comments (0)