83. Remove Duplicates from Sorted List
class Solution {
public:
    ListNode* deleteDuplicates(ListNode* head) {
        if(head == NULL) return head;
        ListNode * A = head;
        ListNode * B = head -> next;
        while(B != NULL){
            if(A -> val != B -> val){
                A -> next = B;
                A = A -> next;
            }
            B = B -> next;
        }
        A -> next = NULL;
        return head;
    }
};
Comments (0)