Peek

Domain: Data Structures

🎯 Motivation

Sometimes you need to see the top of a stack without removing it. Peek lets you look without modifying the stack.

📋 Concrete Example

stack = [1, 2, 3]; top = stack[-1] gives 3 without removing it. The stack stays [1, 2, 3].

🔗 Analogy

Looking at the top plate through the glass door of the cupboard without actually opening the door and taking it.