← eBay Interview Insights

eBay·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jul 2026

Summary

Coding round for a full-stack role at eBay. The recruiter said any language was fine but the interviewer locked it down to JS/TS on the spot, which threw me off since I'm way more comfortable in Python.

Questions Asked (1)

Q1

Implement a function that assigns ads to browser positions for a user. Inputs are a list of position strings, a list of candidate ads, and a per-user state dictionary tracking how many times each ad has been shown. The function should randomly assign ads to positions without duplicates (when supply allows), respect per-ad display limits, return the assignment, and update the state dictionary.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The logic itself wasn't too bad to reason through.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and edge cases, then outline a two-phase algorithm: first filter eligible ads based on per-user display limits, then randomly sample without replacement to assign to positions. Discuss trade-offs between different sampling methods and how to update the state dictionary efficiently.

Pro tip: Mention that you would use a Fisher-Yates shuffle on the eligible ads and then take the first N, which is O(n) and unbiased, and note that if supply is less than positions, you should fill remaining positions with a fallback or leave empty, depending on product requirements.

1. Clarify requirements and edge cases

Ask about the definition of display limits (per ad per user? global?), what to do when there are fewer eligible ads than positions, and whether the assignment should be deterministic given a seed.

2. Design the algorithm

Filter ads that have not exceeded their display limit, then randomly select without replacement up to the number of positions. If not enough ads, decide on a fallback strategy (e.g., repeat ads, leave positions empty, or use a default ad).

3. Implement efficiently

Use a Fisher-Yates shuffle on the eligible ads list and take the first N, or use reservoir sampling if the list is large and N is small. Update the state dictionary by incrementing counts for the selected ads.

4. Analyze complexity and trade-offs

Discuss time and space complexity: O(M) to filter, O(M) to shuffle (or O(N) with reservoir sampling), and O(N) to update state. Compare with alternative approaches like weighted random selection if ads have priorities.

5. Test and validate

Walk through test cases: normal case, insufficient ads, ads at limit, empty inputs. Verify randomness and that state updates correctly.

Key Points to Mention

  • Handling per-ad display limits by filtering eligible ads before selection.
  • Ensuring no duplicate ads in the same assignment when supply allows.
  • Using Fisher-Yates shuffle or reservoir sampling for unbiased random selection without replacement.
  • Updating the state dictionary to reflect the new display counts for future calls.
  • Considering edge cases: insufficient eligible ads, empty inputs, and concurrency if state is shared.
  • Discussing trade-offs between different random selection methods and potential need for weighted randomness.

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