What must memory answer?

Unsorted [8,2,6,9,5], target 7.

At the final 5, which question about earlier input finds the answer?

1 / 11

Choose the stored value

A set answers existence.

A value→index map supplies a witness.

Why must lookup precede insertion on [4,4], target 8?

2 / 11

Ransom Note — predict before coding

Availability is a multiset budget. Seeing a letter once is not enough when the note demands several copies.

Decision: Can note "aa" be constructed from magazine "ab"?

3 / 11

Isomorphic Strings — predict before coding

A consistent forward mapping is not enough: two different source bytes must not collapse to one target byte. The reverse mapping enforces injectivity.

Decision: Why is s="ab", t="aa" false even though a forward map can store a→a and b→a?

4 / 11

Word Pattern — predict before coding

This is a bijection between pattern bytes and whole tokens. Tokenization is part of the contract, not a harmless implementation detail.

Decision: For pattern "abba", why does "dog dog dog dog" fail?

5 / 11

Valid Anagram — predict before coding

Anagrams are exactly equality of frequency vectors. The lowercase alphabet allows a fixed-size difference vector instead of sorting or a general hash map.

Decision: Are "aabb" and "abbb" anagrams, and which counts disprove it?

6 / 11

Group Anagrams — predict before coding

A key should represent the equivalence class, not an accidental property such as total letter sum. Correct canonicalization makes grouping straightforward.

Decision: Why must the two empty strings in ["", "", "a"] remain two entries in one group?

7 / 11

Two Sum — predict before coding

The map is a history of earlier positions. Looking up the complement before inserting the current value prevents one occurrence from pairing with itself.

Decision: Why does [3,3], target 6 require lookup before insertion?

8 / 11

Happy Number — predict before coding

Repeated digit-squaring forms a deterministic functional graph. A visited set or two-speed traversal detects whether its path reaches 1 or enters another cycle.

Decision: What are the first successors of 19 until 1 is reached?

9 / 11

Longest Consecutive Sequence — predict before coding

A set removes duplicates, but linear time also requires iterating distinct starts. Walking from every copy of the same minimum value repeats a whole run.

Decision: For [1,1,1,2,3,4], how many times should the length-four run be expanded?

10 / 11

Reconstruct and transfer

Compare containment with equality.

Explain a reverse-map collision.

Prove linear run expansion by charging each distinct value once.

11 / 11
←/→ or click edges to navigate · ? help · N notes · F fullscreen