class Solution {
public ListNode removeDuplicateNodes(ListNode head) {
Set set = new HashSet<>();
ListNode cur = head;
while (cur != null && cur.next != null) {
//set 元素的值是不重复的
set.add(cur.val);
//包含的的话就删除;
if (set.contains(cur.next.val))
cur.next = cur.next.next;
else
cur = cur.next;
}
return head;
}
}