C++ [Recursive] [5 Lines] [Easiest with comments]


#1
Simplest implementation
ListNode* Solution::deleteDuplicates(ListNode* A) {
        if(A == NULL || A->next == NULL)return A;
        if(A->val == A->next->val){ // skip this node
            return deleteDuplicates(A->next);
        }
        else{ // attach this node to rest of the list
            A->next = deleteDuplicates(A->next);
            return A;
        }
    }