Find the Duplicate Number
A medium-tier problem at 63% community acceptance, tagged with Array, Two Pointers, Binary Search. Reported in interviews at Niantic and 11 others.
Find the Duplicate Number hits your OA from Nvidia, Google, Amazon, and J.P. Morgan regularly. It's a medium-difficulty array problem with a 63% acceptance rate, which means plenty of solid engineers miss it on the first try. The trap is obvious: you can't modify the input, you have O(1) space, and there's always one number repeated at least twice in a range of n+1 integers. If you blank on the cycle-detection pattern during your live assessment, StealthCoder surfaces a working solution in seconds, invisible to the proctor.
Companies that ask "Find the Duplicate Number"
Find the Duplicate Number 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 an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code.
Get StealthCoderMost candidates jump to sorting or hash tables. Both violate the constraints. The real trick is treating the array as a linked list where each value is a pointer to an index. You've got a cycle in that implicit list, and Floyd's cycle-detection algorithm (tortoise and hare) finds it in O(n) time and O(1) space. Two pointers, one slow and one fast. Slow moves one step, fast moves two. They collide inside the cycle. Then reset one pointer to the start and advance both by one step until they meet again. That meeting point is your duplicate. Binary search on the answer range and count works too, but the cycle approach is cleaner and what top-tier interviewers expect. If this pattern doesn't click during prep, StealthCoder is the safety net for a live OA.
Pattern tags
You know the problem.
Make sure you actually pass it.
Find the Duplicate Number recycles across companies for a reason. It's medium-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 an Amazon engineer who realized the OA tests how well you memorized 200 problems, not how well you code. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find the Duplicate Number interview FAQ
Why can't I just use a hash set to track seen numbers?+
The constraint is O(1) space. A hash set grows with input size, violating that hard requirement. Floyd's cycle detection or binary search are the only approaches that fit the constraints and still run efficiently.
Is this still asked at FAANG companies?+
Yes. Google, Amazon, and J.P. Morgan all report this problem. It's not trendy, but it tests core algorithm thinking and constraint optimization. Expect it in rounds focused on optimization rather than breadth-first data-structure problems.
What's the actual trick everyone misses in the interview?+
Treating the array as a linked list via implicit pointers. Once you reframe the problem that way, cycle detection feels natural. Without that reframe, candidates thrash trying to optimize hash tables or sorts. The trick is conceptual, not code.
How does this relate to the Two Pointers and Binary Search topics?+
Two pointers is the cycle-detection path. Binary search works by counting duplicates in ranges. Both are valid O(n) solutions. Two pointers is more elegant and demonstrates deeper algorithmic insight, so practice that one first.
If I freeze on this during my OA, how long does a solution take to write?+
Floyd's approach is 15-20 lines of clean code once the pattern clicks. Binary search is slightly longer. Either way, you're looking at 5-10 minutes of implementation once you've decided on the approach. The first 5-10 minutes are usually spent figuring out which approach fits the constraints.
Want the actual problem statement? View "Find the Duplicate Number" on LeetCode →