Duplicate [mp]
Micro pattern¶
Description¶
Detect, skip, count, or suppress repeated values according to their role in the result.
Problems¶
Check duplicates¶
Use membership, counts, or repeated-state behavior to identify duplicates.
- 217. Contains Duplicate (Top Easy)
- 387. First Unique Character in a String (Top Easy)
- 3. Longest Substring Without Repeating Characters (Top Medium)
- 287. Find the Duplicate Number (Top Hard)
Normalize before deduplication¶
Canonicalize values before inserting them into a uniqueness set.
- 929. Unique Email Addresses (Google Prep)
Skip or count adjacent duplicates¶
Use sorted values or run boundaries to process repeated values together.
- 26. Remove Duplicates from Sorted Array (Top Easy)
- 15. 3Sum (Top Medium)
- 38. Count and Say (Top Medium)
Suppress duplicate search results¶
Deduplicate outputs or remove emitted terminal markers.
- 212. Word Search II (Top Hard)
- 301. Remove Invalid Parentheses (Top Hard)
Deduplicate dependency edges¶
Count a relationship only once when duplicate edges would corrupt a derived degree.
- 1203. Sort Items by Groups Respecting Dependencies (Graph Theory)