Solution with 2 Maps and no List


A solution with two maps, one for the {key value} pair and one for {timestamp, key} pair is also being accepted but the value of timestamp can become very large and go out of the scope of a variable, hence the given solution of using Map + List is better.