Queues

Queues: First Come, First Served at Rush Hour: Queues, Cutting In, and Keeping Only the Last 100: Deques and Ring Buffers.

Updated

  1. First Come, First Served at Rush Hour: Queues (Apprentice): At 8 a.m. the coffee shop's order screen freezes: serving each order from the front of a list moves every order behind it. Find a way to join at the back and serve from the front in one step each, and meet the structure built for it: the queue.
  2. Cutting In, and Keeping Only the Last 100: Deques and Ring Buffers (Journeyman): A paid mobile order jumps to the front of the line, a customer at the back gives up and leaves, and a log must keep only its last 100 lines out of a million. Find the line that's cheap at both ends, and the fixed circle of slots that never moves or grows.