Hello,
This queston has been bugging me for the past 24 hours and I appreciate if someone provides an answer. Why in LRU cache implementation with doubly linked list nodes, the underying node has both key and value as attributes. I think the doubly linked list class can look like this and it works even for duplicate values:
Class DLNode {
int value;
DLNode next;
DLNode prev;
}
I understand if having it defined as below makes the code and solution readable and understandle but don't see any other reason. Am I missing something here?
Class DLNode {
int key;
int value;
DLNode next;
DLNode prev;
}
Thank you,