LinkedList/insert_delete_at_position library

📍 Insert and Delete at Position Algorithms

Algorithms for inserting and deleting nodes at specific positions in a linked list. These operations are fundamental for linked list manipulation.

Time Complexity: O(n) where n is the position or length of list Space Complexity: O(1) for all operations

Functions

deleteAtPosition<T>(LinkedListNode<T>? head, int position) LinkedListNode<T>?
Deletes the node at the specified position
deleteByValue<T>(LinkedListNode<T>? head, T value) LinkedListNode<T>?
Deletes the first node with the specified value
insertAfterValue<T>(LinkedListNode<T>? head, T afterValue, T newValue) LinkedListNode<T>?
Inserts a new node with the given value after a node with the specified value
insertAtPosition<T>(LinkedListNode<T>? head, T value, int position) LinkedListNode<T>?
Inserts a new node with the given value at the specified position