Reported July 2026
eBaybinary search

Single-Pass Search in a Rotated Sorted Array

Reported by candidates from eBay's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live eBay OA. Under 2s to a working solution.
Founder's read

The eBay OA reported in July 2026 hands you a rotated sorted array and one rule that trips people up: a single binary-search loop, no pivot hunt first. Most candidates know the two-pass version cold, so the constraint is the real test. It's the classic search in rotated sorted array, and the whole thing hinges on one question per iteration: which half is sorted? If you blank on that under the clock, StealthCoder runs invisibly during the live assessment and gives you the solution as a safety net. Know the trick first, though. It's about ten lines.

The problem

An integer array nums was originally sorted in strictly increasing order and then rotated at an unknown pivot. Given nums and an integer target, return the index of target, or -1 if it is absent.
Use one binary-search loop. Do not first locate the pivot and then run a second binary search. Your solution must run in O(log n) time.

Function
searchRotated(nums: int[], target: int) → int

Examples
Example 1
nums = [4,5,6,7,0,1,2]
target = 0
return = 4
The target 0 is stored at index 4.
Example 2
nums = [4,5,6,7,0,1,2]
target = 3
return = -1
The target does not occur in the array.

Constraints
1 <= nums.length <= 100000
-2147483648 <= nums[i], target <= 2147483647
All values in nums are distinct.
nums is a rotation of a strictly increasing array.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Pattern is binary search with a sorted-half check. At each step, compute mid. If nums[lo] <= nums[mid], the left half is sorted. Check whether target sits inside [nums[lo], nums[mid]). If yes, move hi left. If no, move lo right. Otherwise the right half is sorted, so do the mirrored check against (nums[mid], nums[hi]]. The edge case that breaks a naive solution is the comparison itself. Use <= when testing nums[lo] against nums[mid], because when lo equals mid the left half is a single element and it's still sorted. Use strict versus inclusive bounds carefully on the target range or you'll skip the answer. Values are distinct, so no duplicate handling is needed. Watch the mid calculation with values near the 32-bit limits, though indices stay small. If the loop logic slips on the live OA, StealthCoder is your hedge to check the boundary conditions.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Single-Pass Search in a Rotated Sorted Array cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as search in rotated sorted array. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass eBay's OA.

eBay reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Single-Pass Search in a Rotated Sorted Array FAQ

What's the trick to the eBay rotated array search?+

Every iteration, one half around mid is guaranteed sorted. Figure out which one by comparing nums[lo] to nums[mid]. Then check whether the target falls inside that sorted half and discard the other half. That keeps it one loop and O(log n).

Why does the problem forbid finding the pivot first?+

Two passes still run in O(log n), but the single-loop version tests whether you can reason about sorted halves directly. It also leaves less room for bugs, since you skip the index-offset math that a pivot-based approach needs.

Which edge case causes the most wrong answers?+

Using < instead of <= when checking nums[lo] <= nums[mid]. With two elements, lo equals mid, and the left half is a single sorted element. Get it wrong and you'll discard the half holding the target. Test with [3,1] and target 1.

Do I need to handle duplicates?+

No. The problem states all values in nums are distinct. That's why the sorted-half check works cleanly. Duplicates would break the comparison and force a linear fallback in some cases, but that's a different problem.

How do I prepare in 48 hours?+

Write the single-loop solution from scratch three times without looking. Then trace it by hand on [4,5,6,7,0,1,2] with targets 0 and 3, plus a one-element array and an unrotated array. Those cases cover nearly every boundary mistake.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with eBay.

OA at eBay?
Invisible during screen share
Get it