链表为有序队列, 直接while对链表值的next进行循环判断即可
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
*/
var deleteDuplicates = function(head) {
let current = head
while (current && current.next) {
if (current.val === current.next.val) {
current.next = current.next.next
} else {
current = current.next
}
}
return head
};