Again, set the current node's next
to point backwards with head.next = newHead;
. Recall that newHead
is 8
! This is where we make the switch:
xxxxxxxxxx
newHead = 8
nextNode = null
// <- 8 <- 4
^
current node
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment