Easy solution in java [ Two pointers || 0ms ]
\n# Code\n\nclass Solution {\n    public ListNode deleteDuplicates(ListNode head) {\n        \n        ListNode dummy = new ListNode(-1);\n        dummy.next = 
\n# Code\n```\nclass Solution {\n    public ListNode deleteDuplicates(ListNode head) {\n        \n        ListNode dummy = new ListNode(-1);\n        dummy.next = head;\n        ListNode pre = dummy;\n        ListNode curr = head;\n\n        while(curr != null) {\n            while(curr.next != null && curr.val == curr.next.val) {\n                curr = curr.next;\n            }\n            if(pre.next == curr) {\n                pre = pre.next;\n            } else {\n                pre.next = curr.next;\n            }\n            curr = curr.next;\n        }\n        return dummy.next;\n    }\n}\n```\n\n---\n\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n---\n![sddefault.jpg](https://assets.leetcode.com/users/images/ce0ffc78-9eb6-4f5d-9a01-38b4f3fb85b5_1718732583.3007364.jpeg)\n\n
['Linked List', 'Two Pointers', 'Java']