Possible Duplicate:
LRU cache design
I got this question in a programming interview. Feel free to think about how you might answer it.
How would you implement an LRU (least-recently-updated) cache in C++? Basically, the cache can hold up to N items. If a new item is inserted and the number of items in the cache is less than N, it's just inserted. But if a new item is inserted and the number of items in the cache is already N, the item that's least recently used should be removed from the cache.
Think about what running time it would take for each of your operation.