Single Element in a Sorted Array
A medium-tier problem at 59% community acceptance, tagged with Array, Binary Search. Reported in interviews at blinkit and 12 others.
You've got a sorted array where every element appears twice except one, and you need to find that single element. Sounds straightforward until you write the naive O(n) pass and realize the interviewer is waiting for O(log n). Blinkit, Nvidia, ServiceNow, and Coupang have all asked this. The trick isn't obvious on first read, and if you blank during your assessment, StealthCoder surfaces the binary search pattern in seconds, invisible to the proctor. This is a medium-difficulty problem that catches a lot of candidates who skip the binary search fundamentals.
Companies that ask "Single Element in a Sorted Array"
Single Element in a Sorted Array 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 StealthCoderThe trap is thinking you can just hash or count. You can, but that's not what they want. The insight is that the single element breaks a pattern in the array. Before the single element, pairs are at even indices (0,1), (2,3), (4,5). After it, pairs flip to odd indices (1,2), (3,4). Binary search exploits this flip point. You narrow the search space by checking whether the current pair matches the pattern, then move left or right accordingly. Most candidates either miss the pattern shift entirely or get confused by the index arithmetic. If you hit this live and the pattern doesn't click, StealthCoder runs the solution in real time, no screen-share footprint. Common mistake: forgetting to handle the case where the single element is at an edge, or confusing which index should be even vs. odd.
Pattern tags
You know the problem.
Make sure you actually pass it.
Single Element in a Sorted Array 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 a senior engineer who knows the OA is theater. This is the script. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Single Element in a Sorted Array interview FAQ
Why is this a medium, not easy?+
Because the linear scan works but doesn't satisfy the implicit O(log n) requirement. The binary search pattern that checks pair positions and index parity is what separates 'I know binary search' from 'I can apply it.' Acceptance rate is around 59%, which reflects that many candidates submit working but suboptimal solutions.
Is the pair-index pattern the actual trick?+
Yes. Before the single element, it appears at even indices. After it, odd indices. You use that to binary search the breakpoint. If mid's pair is where it should be, the single element is to the right. Otherwise left. Index arithmetic matters more than the values themselves.
Do I need to handle duplicates or is every pair exact?+
Every pair is the exact same value. The problem is cleaner than some variants. You don't worry about which duplicate to keep. Just find where the pairing breaks and that breakpoint tells you which half contains the single element.
Is this still being asked at major companies?+
Yes. It's live across Nvidia, ServiceNow, Snowflake, Pinterest and others. It's a classic that tests whether you can recognize a binary search opportunity in a non-obvious context. Companies use it to filter for solid algorithm fundamentals, not just code-and-ship.
What's the biggest pitfall on the whiteboard?+
Off-by-one errors in index checks or confusing which half to search based on whether mid's pair is at an even or odd position. Also, not considering the single element could be at the very start or very end. Write out a few examples on paper before you code.
Want the actual problem statement? View "Single Element in a Sorted Array" on LeetCode →