LinkedList/remove_nth_from_end library
🗑️ Remove Nth Node From End Algorithm
Efficient algorithm to remove the nth node from the end of a linked list using the two-pointer technique. This is a common interview problem.
Time Complexity: O(n) where n is the length of the list Space Complexity: O(1)
Functions
-
removeNthFromEnd<
T> (LinkedListNode< T> ? head, int n) → LinkedListNode<T> ? - Removes the nth node from the end of the linked list
-
removeNthFromEndRecursive<
T> (LinkedListNode< T> ? head, int n) → LinkedListNode<T> ? - Removes the nth node from the end using recursive approach
-
removeNthFromEndSinglePass<
T> (LinkedListNode< T> ? head, int n) → LinkedListNode<T> ? - Removes the nth node from the end using single pass with length calculation
-
removeNthFromEndWithReturn<
T> (LinkedListNode< T> ? head, int n) → Map<String, LinkedListNode< T> ?> - Removes the nth node from the end and returns both the new head and the removed node