class Solution
{
function removeDuplicateNodes($head) {
if($head == null || $head->next == null) {
return $head;
}
$hash = [];
$cur = $head;
while($cur != null){
$hash[$cur->val] = 1;
while($cur->next != null && $hash[$cur->next->val] == 1){
$cur->next = $cur->next->next;
}
$cur = $cur->next;
}
return $head;
}
}