1->2->3->4->*1 ==> 1->2->3->*1
head
and make its previous node point to the head node.
1. Traverse over to the node which points to head
. Call it currentNode
. Keep track of the node which points to this node - prevNode
.
2. Point prevNode
's next
to head
.
3. Point currentNode
's next
to null
.
4. Return the original head
.
public ListNode deleteAtTail(ListNode head) { }
C
Java
Python