LC 217
LeetCode 217 · Easy

Contains Duplicate

Return true if any value appears at least twice in the array.

Hash map → · High frequency · Solve on LeetCode →

Try it

Step through the core mechanic. The simulator below runs the hash map shape this problem is built on.

Walk the pattern

No dedicated step-through for this one yet. The shape is Hash map — its pattern page has the interactive walkthrough, the reference implementation, and a five-problem progression that this problem sits inside.

The approach

Stream into a hash set; if an insert finds the value already present, return true. Equivalent: compare len(set(nums)) with len(nums).

AspectValue
PatternHash map
Recognise it byAny value repeats? Membership in O(1).
Time complexityO(n)
Space complexityO(n)
DifficultyEasy

Who asks it

Companies known to ask this problem, from public LeetCode company-tag aggregations. A signal of where to expect it, not a guarantee.