Design problems hand you a blueprint with promised costs. Keep a little extra next to the data, like a map or a second value, so every method runs in constant time.
▼Transcript
Welcome to the Design world. Here you don't solve one puzzle. You build a class that answers call after call, fast.
You get a blueprint: a few methods, each with a promised cost, usually constant time. Your job: pick the state behind them.
The simplest state is a plain list. Putting a new item is quick: add it to the end. But get has to scan from the front: six items, six steps. That's O of n.
So add better state. Snap on a key map that points straight at each item. Now get is one hop, and put adds one entry.
Size? Keep a counter, and bump it whenever a new key arrives. That's the whole move: store a little extra, so each call does less. Later stages keep a second value, or links.
The clue: the problem says design or implement a class, and each function must run in O of one, often on average.
Each call stays constant time. You pay in memory: one entry per item, so linear space.
Now let's use it on Design HashSet.