InterviewLegend

Heaps and Binary Search

Alex Chen40 min readUpdated 266 real interview reports

Heap and binary search problems at eBay tend to come with a second question about cost. A heap problem can fill a whole phone screen or show up as a quick follow-up after a longer array question. Binary search problems have turned up both on the online assessment and in live rounds.

The interviewer often pushes past your first working answer. In one live round, a two-step search was turned down and the candidate was asked for a single binary search. On another problem, a heap holding every value passed the visible tests and was still called short of optimal, because a much smaller heap was enough.

Some problems arrive with a new story around a familiar search, especially in eBay's India hiring drives. Set the story aside and look for the sorted order, or the yes or no check you can binary search over.

Watch for integer overflow in Java too. eBay's services run on Java, and interviewers have flagged (lo + hi) / 2 in a binary search, so write lo + (hi - lo) / 2 from the start. Each problem below starts with the simple version and its cost, then builds the faster one.

eBayPremium lesson · Coding round

The 4 eBay problems are below.

  1. A Premium questionCoding · Medium
  2. A Premium questionCoding · Medium
  3. A Premium questionCoding · Medium

+ 1 more in this lesson

Each with hints, the follow-up and a tested solution.

Get the eBay questions

$49 a year · all 100 companies · cancel anytime

From 266 eBay reports, forum threads behind logins and write-ups in Chinese.

Had your eBay interview?Tell us what they asked. Reviewed before it goes in, never with your name.
eBay interview guide

Know what eBay asks before you walk in.

33 coding · 5 system design · 30 behavioral questions

Get Premium$49 a year · Cancel anytime
Or start freeNo card.

Get their questions first.

InterviewLegend is independent and not affiliated with or endorsed by any company it covers.