I am stuck on an exercise in Problem Solving with Algorithms and Data Structures. The exercise says that one can implement a queue in which enqueue and dequeue are both O(1) on average and that there is one circumstance when dequeue is O(n).
The only thing I could think of was to use a list in which the front (dequeue side) of the queue is tracked by an index of the list. In this enqueue is at the end (i.e., an append which is O(1)) and dequeue operates by copying the current "front" element and then moving the front index tracker forward. But this is massively space costing and is not the target answer because is always O(1) in both.
Any thoughts on this?