Match Bid Requests to Line Items With an Inverted Targeting Index
Last updated: November 29, 2026
Quick Overview
Each line item targets a set of allowed values per dimension (geo, device, audience segment); a missing dimension means any value. Build an index so that, for an incoming bid request with one value per dimension, you return every eligible line item quickly.
StackAdapt
November 29, 20260
0
0 solved
Each line item targets a set of allowed values per dimension (geo, device, audience segment); a missing dimension means any value. Build an index so that, for an incoming bid request with one value per dimension, you return every eligible line item quickly.
Before a StackAdapt bidder can price an impression it has to find which of many thousands of active line items are allowed to bid, all inside a tight latency budget. Scanning every line item per request does not scale, so the onsite checks whether you reach for an inverted index with counting.
What the Interviewer Expects
- Explains why a linear scan over line items per request is too slow
- Builds postings from (dimension, value) to line items
- Uses a hit count equal to the number of constrained dimensions to decide a match
- Handles untargeted line items and requests missing a dimension
- Discusses update cost when campaigns change
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
- A user belongs to 40 audience segments; how does matching change when a request has many values per dimension?
- How do you support exclusion rules such as not in these domains?
- How would you rebuild the index without pausing bidding?
- How would you add budget and frequency eligibility to the filter cheaply?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
A line item matches a request when, for every dimension it constrains, the request's value for that dimension is in the allowed set. Unconstrained dimensions match anything. A line item that constrain...
High-Level Design
For each line item, count its constrained dimensions. Build postings[dimension][value] -> [line items]. For a request, walk its dimensions, pull the posting list for each (dimension, value) and incr...