Last Kth Node of Linked List
Question
Given a linked list, find the Kth last node in a linked list. The last 0th node is the tail node in the linked list.
Solution
Easy task. Construct 2 pointers: P1 and P2. First, both of them are set to head. Then move P2 to the next (K+1)th node. And then move both P1 and P2 until P2 hits the end.