← StubHub Interview Insights

StubHub·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
May 2026Remote

Summary

StubHub coding round for a software engineer role, one meaty design-your-own-feature problem that took up the whole session. The problem sounded manageable at first but the efficiency discussion at the end is where things got real.

Questions Asked (1)

Q1

You're extending a MarketingEngine class that holds a collection of events and supports per-customer notification campaigns. Add a campaign that finds the single event whose date is closest to a given customer's next upcoming birthday, handles ties deterministically, and explain how to do this efficiently.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The core logic wasn't too bad.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

First, clarify the requirements: define 'closest' as the minimum absolute difference in days between each event date and the customer's next birthday, and specify tie-breaking rules (e.g., earlier event date wins). Then, propose an efficient algorithm: sort events by date once (O(n log n)) and use binary search (O(log n)) per query to find the closest event, handling ties by comparing the two candidates around the insertion point.

Pro tip: Mention that you would encapsulate the tie-breaking logic in a comparator or a dedicated method to ensure deterministic behavior and make it easy to change later, and discuss the trade-off between pre-sorting (faster queries) and sorting per query (simpler but slower).

1. Clarify requirements and edge cases

Define what 'closest' means (absolute difference in days), how to compute the next upcoming birthday (including handling Feb 29), and specify tie-breaking rules (e.g., earlier event date, or event with smaller ID).

2. Choose an efficient data structure

Decide whether to sort events by date once and maintain the sorted order, or use a balanced BST. Sorting once is O(n log n) and enables O(log n) queries via binary search.

3. Implement the closest-event search

For a given customer, compute the next birthday date, then use binary search to find the insertion point in the sorted events. Compare the event just before and just after the insertion point to find the closest.

4. Handle ties deterministically

If both candidates are equally close, apply the tie-breaking rule (e.g., choose the earlier event date). Ensure the rule is consistently applied and documented.

5. Analyze complexity and trade-offs

State the time complexity: O(n log n) preprocessing, O(log n) per query. Discuss alternatives (e.g., linear scan O(n) per query) and when they might be acceptable.

Key Points to Mention

  • Binary search on sorted event dates to achieve O(log n) query time.
  • Tie-breaking rule: e.g., prefer the event with the earlier date, or the one with the smaller ID if dates are equal.
  • Handling of next birthday calculation, including leap years (Feb 29) and time zones if relevant.
  • Edge cases: no events, customer birthday far in future/past, multiple events on same date.
  • Trade-off between preprocessing (sorting) and per-query cost; mention that if queries are frequent, sorting once is beneficial.
  • Deterministic behavior: ensure the tie-breaking logic is consistent and testable.

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