Any idea how to solve this one?
Anonymous User
375

Given a queue with operations such as push()and pop() and another attribute named version number which is incremented each time an operation is perfomed on the queue find the state of the queue at a particular version number without using a lot of memory.

Example:

Input: [[0,1],[0,2],[1],[1],[0,3]], version=3
Output: [2]
Explanation: Version 1: [1], Version 2: [1,2], Version 3: [2], Version 4: [], Version 5: [3]

Format: Push = [0,element], Pop = [1]

Comments (1)