I was trying to solve the problem to remove head in a doubly linked list in Java here is the link to that problem
During the 4th step it states that
Still above the final
return statement, check if
removedHead is equal to the list’s tail. If so, call the
.removeTail() method. We will create this in the next exercise, so comment the method call out for now.
My question is that we are only concerned with removing the head of the list
So if we consider a case of this doubly linked list in which I have the following elements
1 - 2 - 3 - 4
Removing a head on this should remove 1
and now I simply have to set 2’s previous pointer to null and my current head to 2
So why the condition to check if
removedHead is equal to the list’s tail?