cache-low-level-system-design
cache-low-level-system-design copied to clipboard
DoublyLinkedList.java
In class DoublyLinkedList, the method detachNode(), Here we need to check the node that we are deleting having prev and next not null as: case 1 : if(node.prev!=null){ node.prev.next = node.next; }else{ dummyHead = node.next; // if the node is head then we need to move the head . } case 2 : if(node.next!=null){ node.next.prev = node.prev; }else{ dummyTail = node.prev; // if the node is tail then we need to move the tail. }