You are given the head of a singly linked list of integers. Modify the list in place so that it contains only the first occurrence of each value (i.e., remove any node whose value has already appeared earlier in the list).
data
(integer)
next
(reference to next node, or
null
at the tail)
Return the head of the updated linked list.
3 -> 4 -> 3 -> 6
3 -> 4 -> 6
3 -> 4 -> 3 -> 2 -> 6 -> 1 -> 2 -> 6
3 -> 4 -> 2 -> 6 -> 1