Can someone please explain how it is getting the correct output when we are not updating the "head"?
public ListNode deleteDuplicates(ListNode head) {
ListNode slow = head;
while (slow.next != null) {
if (slow.val == slow.next.val) {
slow.next = slow.next.next;
}
else {
slow = slow.next;
}
}
return head;