Given the head of a linked list, remove the nth node from the end of the list and return its head.
This problem uses a variation of the two-pointer technique where the gap between pointers helps us locate a specific position from the end. By maintaining a fixed gap of n nodes between two pointers and advancing both until the fast pointer reaches the end, the slow pointer will be perfectly positioned.
head = [1,2,3,4,5], n = 2[1,2,3,5]head = [1], n = 1[]head = [1,2], n = 1[1]The number of nodes in the list is sz1 <= sz <= 300 <= Node.val <= 1001 <= n <= szClick "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers