Flag Suspiciously Underpriced Listings With a Rolling Median
Last updated: November 29, 2026
Quick Overview
Given a time-ordered stream of new listings (time, listing id, price) for one section of an event, flag each listing whose price is below a ratio times the median price of listings created in the preceding window, when at least a minimum number of peers exist.
StubHub
November 29, 20260
0
0 solved
Given a time-ordered stream of new listings (time, listing id, price) for one section of an event, flag each listing whose price is below a ratio times the median price of listings created in the preceding window, when at least a minimum number of peers exist.
Listings priced far below comparable seats are a classic signal of fraud or a seller typo on a ticket marketplace, and StubHub's trust and safety pipeline needs a cheap, streaming baseline for 'comparable'. The interviewer wants a correct rolling median with insertions and deletions, which means two heaps with lazy deletion and careful size bookkeeping.
What the Interviewer Expects
- Explains why a mean is a poor baseline (outliers and broker floods)
- Maintains a sliding time window with a deque of (time, price)
- Implements a two-heap median that supports removal via lazy deletion
- Tracks logical heap sizes separately from physical heap lengths
- Compares only against prior listings, not the listing itself
- Validates against a brute-force version
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you partition this across thousands of events and sections in a stream processor?
- Seat quality varies within a section. How would you choose the peer group?
- What would you do with a flagged listing: block, hold for review, or warn the seller?
- Could you replace the exact median with an approximate quantile sketch, and what would you lose?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
For each listing at time t, peers are earlier listings in the same section with time in (t - window, t). If there are at least min_peers, flag when price < ratio * median(peers). Then the listin...
High-Level Design
A deque holds the window in arrival order so old prices can be evicted. The median needs add, remove and query, so use a max-heap lo for the smaller half and a min-heap hi for the larger half, wit...