Object-Oriented Programming · ByteDance · Medium
Create a doubly linked list that supports these actions: addAtHead(int val): Insert a new node containing val at the front of the list. addAtTail(int val): Place a new node containing val after the current last node. addAtIndex(int index, int val): Insert a node holding val immediately before the node at position index. When index matches the current list length, add the node at the end instead. If index exceeds the list length, leave the list unchanged. For a negative…