Stacks and Queues solutions