Problem of the Day: Stacks & Queues

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.

> [5]

> [5,6]

> [7,5,6]

> 7

> 5

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!

Stacks & Queues


One response to “Problem of the Day: Stacks & Queues

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: