1
var deleteDuplicates = function (head) {2
const dummy = new ListNode();4
let node = dummy; // the last known distinct node6
if (node.next.next && node.next.val === node.next.next.val) {7
// if the next two nodes are equal...8
let nonValNode = node.next.next.next;9
while (nonValNode && nonValNode.val === node.next.val) {10
// ...find the first one that isn't...11
nonValNode = nonValNode.next;13
node.next = nonValNode; // ...and glue it to the last known distinct node;...15
node = node.next; // ...otherwise the next node is distinct