Nice work making it through the Hashing section! Across six problems, you practiced the same core move again and again: decide what a later step needs to know, then write down exactly that so you never have to scan the same values twice.
Here’s how that idea showed up in each exercise:
- Repeated Values: A set of the values you’d already seen turned every rescan into a single membership check.
- First Unique Character: Knowing that a character existed wasn’t enough. You needed counts, plus a second pass that respected the original order.
- Matching Character Counts: Comparing two sets looks right until two strings share the same letters in different amounts. The multiplicities decide the answer, so a set throws away exactly what you need.
- Target Pair Positions: Storing each value’s index and looking up its complement before storing the current value kept an index from pairing with itself.
- Shared Inventory: Counts from one list could be spent down while you read the other, which preserved the smaller multiplicity.
- Consecutive Value Run: A set gave you fast lookups, and counting only from the start of each run kept the total work linear.
Each of these solutions spends extra memory to buy O(n) average time. When you explain a solution in an interview, name that tradeoff and say what your stored entries represent at every step.
Maybe some of these went smoothly on the first try, while others took a handful of red test runs and a hint or two. That’s completely normal! Those bumpy attempts are where the learning happened, and they point to the part of the idea that hasn’t fully settled yet. Take a moment to pick the exercise that took you the most attempts. In two or three sentences, explain what first went wrong and what changed your mind.