# Cutting In, and Keeping Only the Last 100: Deques and Ring Buffers

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.

![Cheat sheet: Cutting In, and Keeping Only the Last 100: Deques and Ring Buffers](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/358ccce711934a9ca6721bf5803d5edd.webp)

- Category: Data Structures
- Level: Journeyman
- Tags: data structures, Deque (data-structures), Modulo (software-development), Queue (data-structures), Ring Buffer
- Updated: November 3, 2026

Source: https://www.ask-codey.com/cheat-sheets/ds-deques-and-ring-buffers-cheat-sheet
