Remove -th Node from End of List
https://leetcode.com/problems/remove-nth-node-from-end-of-list/
- Use
preheadtechnique - Instead of a stack, use two pointer to specify the window
prehead = ListNode(0)
prehead.next = head
first = second = prehead
for _ in range(n + 1):
first = first.next
while first:
first = first.next
second = second.next
second.next = second.next.next
return prehead.next