← Hash Map

Pattern Recognition Drill

#26 — Ice cream parlor

Easy Hash Maps

The Problem

Given prices and a budget, find two items that sum to exactly the budget.

What approach would you use?

Think about it before scrolling down.

Key Signals

Hash Map

Identical to two sum. For each price, check complement in hash map. O(n).

Alt: Two Pointers

Sort prices + two pointers. O(n log n). Need to map back to original indices.

Common Trap

Recognize this as a two-sum variant — don't overthink the story framing.

← #25 #27 →