EASYasked at 19 companies

Contains Duplicate

A easy-tier problem at 63% community acceptance, tagged with Array, Hash Table, Sorting. Reported in interviews at Paycom and 18 others.

Founder's read

Contains Duplicate looks deceptively simple. You scan an array and return true if any element appears twice, false otherwise. It's asked at Amazon, Netflix, Airbnb, Palantir, and Bloomberg. The acceptance rate sits at 63%, which sounds high until you realize the trick isn't obvious under time pressure on a live assessment. Most candidates either waste time sorting or write code that passes small test cases but TLEs on large ones. If this problem hits your assessment and you blank on the optimal approach, StealthCoder surfaces a working solution in seconds, invisible to the proctor.

Companies asking
19
Difficulty
EASY
Acceptance
63%

Companies that ask "Contains Duplicate"

If this hits your live OA

Contains Duplicate is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by a senior engineer who knows the OA is theater. This is the script.

Get StealthCoder
What this means

The naive approach is O(n^2): nested loops checking every pair. Slightly smarter is sorting first, then scanning for adjacent duplicates, O(n log n). Both fail on large inputs. The real solution is a hash table (or set). You iterate once, adding elements as you go. If you see an element that's already in the set, you return true immediately. O(n) time, O(n) space. The trick candidates miss: they either over-engineer it, worry about space complexity when it doesn't matter here, or implement the hash table incorrectly. When you hit the wall on this during a live OA, StealthCoder gives you the hash table pattern and confirmed code in under five seconds.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Contains Duplicate recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Contains Duplicate interview FAQ

Is Contains Duplicate really asked at FAANG?+

Yes. It appears in reports from Amazon, Netflix, Airbnb, and Bloomberg. It's a warm-up or early-round screen at these companies. The acceptance rate of 63% suggests it filters out candidates who can't quickly identify the hash table pattern.

Why does sorting fail on the live assessment?+

Sorting is O(n log n). On arrays with millions of elements, that timeout. Interviewers also deduct points for not recognizing that hash table is simpler and faster here. It's a pattern recognition test, not a sorting test.

What's the real trick to Contains Duplicate?+

Stop thinking about comparisons. Use a set. Add each element. If it's already there, return true. One pass, O(n). The 'trick' is knowing when a hash table is the right tool, not solving the problem with brute force.

Does space complexity matter for this problem?+

No. O(n) space for the set is acceptable and expected. Interviewers ask about space to see if you understand the tradeoff, not to penalize you for using a set. Mention it, move on.

How does Contains Duplicate relate to the Array and Hash Table topics?+

It's a canonical pairing. The problem is about arrays, but the solution lives in hash tables. Mastering this teaches you when and why to trade space for speed, a pattern you'll see in harder problems from both topics.

Want the actual problem statement? View "Contains Duplicate" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.