A short and simple Java solution
public ListNode deleteDuplicates(ListNode head) {\n        ListNode dummy = new ListNode(0);\n        ListNode d = dummy;\n        while (head != null) {\n     
    public ListNode deleteDuplicates(ListNode head) {\n        ListNode dummy = new ListNode(0);\n        ListNode d = dummy;\n        while (head != null) {\n            if (head.next != null && head.val == head.next.val) {\n                while (head.next != null && head.val == head.next.val)\n                    head = head.next;\n            } else {\n                d.next = head;\n                d = d.next;\n            }\n            head = head.next;\n        }\n        d.next = null;\n        return dummy.next;\n    }\n\n1->1->1->2->2->3\n\nwe skip all the 1's and start the loop from 2\n\nand also skip all the 2's, and now head.val == 3;\n\nponit d.next to the tail, end the loop
[]