predecessor
to point to the sentinel node and current
to point to the head of the list.current
is not null.current.next
is not null and current.val
is equal to current.next.val
, keep moving current
forward to skip over duplicates.current
has moved (indicating duplicates were found), set predecessor.next
to current.next
to skip the entire duplicate sublist. Otherwise, move predecessor
forward.current
forward to the next node.sentinel.next
as the new head of the modified list.