← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

eBay software engineer coding round, one problem the whole session. The problem looked like a simple mapping exercise but the edge cases around reuse and limit tracking made it trickier than expected.

Questions Asked (1)

Q1

Write a function that assigns ads to browser positions for a single user, given a list of positions, a list of candidate ads with per-user display limits, and the user's current ad display counts. The function should randomly assign eligible ads to positions, avoid duplicate assignments when possible, allow reuse only when limits still permit it, increment counts on each assignment, and return both the assignment map and the updated state.

Algorithms & Data StructuresSystem Design
Author's notes

My first pass totally ignored the reuse case.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify the requirements and edge cases first, then outline a greedy randomized algorithm that filters eligible ads, shuffles them, and assigns while tracking counts. Discuss time/space complexity and potential optimizations like weighted random selection or handling large-scale systems.

Pro tip: Mention that in production systems like eBay's, ad assignment often involves additional constraints (e.g., pacing, targeting) and randomization may be weighted by bid or relevance; showing awareness of these real-world factors demonstrates maturity.

1. Clarify Requirements and Edge Cases

Ask about input/output formats, definition of 'eligible' (e.g., remaining limit > 0), behavior when no eligible ads exist, and whether positions can be left unassigned. Confirm if duplicate avoidance is strict or best-effort.

2. Design the Algorithm

Propose a greedy approach: filter ads with remaining limit > 0, shuffle them, then iterate over positions assigning ads while avoiding duplicates if possible. If duplicates are unavoidable, reuse ads with remaining limit > 0.

3. Handle State Updates and Return Values

Increment the display count for each assigned ad and update the user's state. Return both the assignment map (position -> ad) and the updated counts.

4. Analyze Complexity and Discuss Optimizations

State time complexity O(P * A) where P is positions and A is ads, and space O(P + A). Discuss potential improvements like using a priority queue for weighted random selection or pre-filtering ads.

5. Test with Examples and Edge Cases

Walk through a simple example, then test edge cases: no eligible ads, more positions than eligible ads, and ads with zero remaining limit. Ensure the solution handles these gracefully.

Key Points to Mention

  • Eligibility criteria: ads with remaining display limit > 0
  • Randomization: shuffle eligible ads to ensure fairness
  • Duplicate avoidance: try to assign unique ads to positions; reuse only when necessary
  • State management: increment counts and update user's ad display counts
  • Complexity analysis: time and space, and potential optimizations
  • Edge cases: no eligible ads, insufficient ads, and zero limits

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.