Prompt
Count distinct case-insensitive alphanumeric characters that appear more than once in a string. Non-alphanumeric characters are ignored.
Solution
Another frequency-map problem, with a twist in what gets counted: not occurrences, but distinct characters whose occurrence count exceeds one. That distinction — "how many characters repeat" vs "how many repetitions" — is the reading-comprehension trap; "aaa" contributes 1, not 2 or 3.
The shape: normalize (lowercase + strip non-alphanumerics with /[^a-z0-9]/g), build the histogram in one pass, then count values > 1 via Object.values. O(n) time, O(k) space where k is alphabet size — effectively O(1) space for ASCII input, since the map can't exceed 36 keys.
The naive alternative is the by-now-familiar O(n²): for each character, count its occurrences with a nested scan, plus bookkeeping to avoid double-counting the same character. The histogram does both jobs — counting and dedup — in one structure, because each distinct character is exactly one key.
Normalization order matters less here than in the isogram (lowercase and strip commute), but doing both before counting keeps the counting loop dumb, which is the point: push all input-cleaning to the edges, keep the algorithm core trivial. Same principle as validating at the API boundary instead of inside business logic.
Red flag: returning total surplus occurrences ("aaa" → 2) instead of distinct repeated characters ("aaa" → 1) — re-read the prompt before coding. Also forgetting case-folding, so "Aa" reports 0.
Say it: "One histogram pass after normalizing, then I count keys with a value above one — distinct repeated characters, not repetitions, which is the trap in the wording."