← stubhub Interview Insights

stubhub·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

StubHub coding round for a software engineer role. One meaty design-your-way problem that looked like OOP at first but turned into a mini algorithms discussion by the end.

Questions Asked (1)

Q1

You're extending a MarketingEngine class that holds a collection of events. Each customer has a city and a birthday, each event has a city and a date. Add a method that finds the single event whose date falls closest to the customer's next upcoming birthday and returns it for notification. Handle ties with a deterministic tiebreaker. Also discuss how you'd make this efficient.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

The birthday logic tripped me up more than I expected.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: define 'next upcoming birthday' relative to the current date, and 'closest' as the minimum absolute difference in days between the event date and that birthday. Then outline an algorithm that computes the next birthday for the customer, iterates through events to find the closest, and applies a deterministic tiebreaker (e.g., earliest event date, then event ID). Finally, discuss efficiency improvements like pre-sorting events by date or using a balanced BST for O(log n) queries.

Pro tip: Mention that you would handle edge cases like February 29 birthdays and events in different time zones, and that the tiebreaker should be documented and consistent to avoid non-deterministic behavior in production.

1. Clarify requirements and edge cases

Define 'next upcoming birthday' (e.g., if today is after this year's birthday, use next year's), and specify the tiebreaker (e.g., earliest event date, then event ID). Consider leap years and time zones.

2. Design the algorithm

Compute the customer's next birthday date. Iterate through all events, calculate the absolute difference in days between each event date and the birthday, and track the event with the smallest difference. Apply the tiebreaker when differences are equal.

3. Analyze complexity and optimize

The naive approach is O(n) per query. For efficiency, pre-sort events by date and use binary search to find the closest event to the birthday, reducing query time to O(log n) after O(n log n) preprocessing.

4. Discuss trade-offs and scalability

Compare linear scan vs. sorted array vs. balanced BST. Consider memory, update frequency, and whether multiple customers will query the same event collection. Mention caching or indexing if needed.

5. Summarize and conclude

Recap the chosen approach, emphasizing correctness, determinism, and efficiency. Mention any assumptions made and how you would test edge cases.

Key Points to Mention

  • Definition of 'next upcoming birthday' and handling of leap years (Feb 29).
  • Deterministic tiebreaker: e.g., earliest event date, then event ID.
  • Time complexity: O(n) naive vs. O(log n) with pre-sorted events and binary search.
  • Space-time trade-off: sorting events once vs. scanning per query.
  • Edge cases: no events, multiple events on same date, customer birthday today.
  • Potential use of data structures like balanced BST or segment tree for dynamic updates.

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