/*
* function ListNode(x){
* this.val = x;
* this.next = null;
* }
*/
/**
*
* @param head ListNode类
* @return ListNode类
*/
function deleteDuplicates(head) {
// write code here
if (head == null) return head;
const dummyNode = new ListNode(-1);
dummyNode.next = head;
let cur = dummyNode;
while (cur.next && cur.next.next) {
if (cur.next.val === cur.next.next.val) {
const temp = cur.next.val;
while (cur.next && cur.next.val === temp) {
cur.next = cur.next.next;
}
} else {
cur = cur.next;
}
}
return dummyNode.next;
}
module.exports = {
deleteDuplicates: deleteDuplicates,
};