One data structure that can do both stack and queue functions. The underlying structure will be a double-linked-list because I haven’t used much of those lately.
Stacks && Queues
Glad you’re back for another great week!
Today’s problem is about combining two common data structures in to one. Your goal is to implement a data structure that can pop and push like a stack and also dequeue and enqueue like a queue. Here is an example of how your data structure should work.
Note: pop and dequeue will essentially do the same thing since they always pull from the front of the line. As always, bonus points for efficiency!