EasyArray · Sorting · Hash Set
LeetCode #217

Contains Duplicate

Given an integer array, return true when any value appears at least twice; otherwise return false.

In very simple words

Ask one question: Did I see any number more than once?

[1, 2, 3, 1]

true — 1 appears twice

[1, 2, 3, 4]

false — every value is unique

Have you solved it before?

The final answer stays hidden in both modes.

Solve It With Small Hints

Read one hint, pause, and try again before opening the next.

Step 1

Say the question in your own words

Return true if any number appears more than once. Return false if every number appears only once.

[1, 2, 3, 1] contains another 1, so the answer is true.

Complete Answer

Both approaches, dry runs, Go code, complexity, and mistakes.

The solution is hidden. Use the guided hints first so you still solve the problem yourself.