The Code Kata Challenge has past but today let’s review the code from our 3rd place winner who takes home the first copy of Are You Smart Enough to Work at Google?.
Challenge review:
- Implement a queue class using 2 stacks internally
- The queue class should implement an insert and retrieve method
- The 2 internal stacks should implement push and pop methods
Third place goes to Steve!
While Steve’s solution is clean it also gets extra points for efficiency.
Chris’ honorable mention post took the approach to copy everything in stack 1 (the add/insert stack) over to stack 2 except for the final element in stack 1, which was to be returned from the overall retrieve method, and then copy everything in stack 2 back over to stack 1, for every retrieval (in case another insert operation occurs in between retrievals).
However this isn’t quite necessary, as Steve’s solution and later solutions will show. For the efficiency of the solution, it is awarded third place.
Steve – Great work!
Invitations still available – so join us for Code Kata Night on July 10th from 3-5pm!