1756. Design Most Recently Used Queue
Design a queue-like data structure that moves the most recently used element to the end of the queue.
Implement the MRUQueue class:
- MRUQueue(int n) constructs the MRUQueue with n elements: [1,2,3,…,n].
- int fetch(int k) moves the kth element (1-indexed) to the end of the queue and returns it.
c++
1 | class MRUQueue { |