Just launched! Get 30% off Rails Revisited Have a Look

Jon Skeet: Creating a Queue from Scratch

Buy or Subscribe

You can access this course in just a minute, and support my efforts to rid the world of crappy online courses!

Buy Standalone  Subscribe

This question is a bit simpler - but if you're a C# person it might be a bit from left field as .NET folks typically don't think about stacks and queues very much. It's a good thing to know as they're used in interviews quite often.

This question is a bit vague as I decided to “evolve” it as Jon coded. I started with:

Assume there are no other list types in .NET other than a Stack and a Linked List. Create a Queue

Which evolved to …

Create a Queue from two stacks.

If you want to follow along in JavaScript feel free. An Array can be used as a stack with push and pop.