Easy solution O(n)


#1
public class Solution {
    public ListNode deleteDuplicates(ListNode list) {
        if(list.next == null) return list;
        ListNode cur = list, next = cur.next;
        while(cur != null) {
        while(next!=null && cur.val == next.val) {
            next = next.next;
        }
        cur.next = next;
        cur = next;
        }
        return list;
    }
}

#2

baap re baap,
very elegant solution, i was over analyzing corner cases and almost gave up on this but your solution made me learn .