This can be solved real quick even without using a list. Think about what all you need. You need a key , a value and a time stamp. You would definately need a map of (key,value). Now how to access key from time and time from key. Its simple. Use a map of (key,time) and a set of (time , key). I used them both because you would need to find the timer of a key and update it in O(logN) and at the same time , we also need to find the key with least time. A set of (key , value) would be best suitable for this.