Detect Near-Identical Bids Placed Within K Auctions of Each Other
Last updated: November 29, 2026
Quick Overview
Given a sequence of bids, return whether two bids at most k positions apart differ in amount by at most t. This flags possible bid-shading bots in the ads auction.
Meta
November 29, 20260
0
0 solved
Given a sequence of bids, return whether two bids at most k positions apart differ in amount by at most t. This flags possible bid-shading bots in the ads auction.
A Meta onsite hard question with an ads integrity framing. A sliding window plus an ordered set (floor and ceiling lookups) is the textbook answer; strong candidates also give the O(n) bucketing solution and explain why only adjacent buckets need checking.
What the Interviewer Expects
- Maintain a sliding window of the last k bids
- Offer an ordered set with ceiling(bid - t) in O(n log k)
- Improve to O(n) with buckets of width t + 1
- Explain why at most one value per bucket can exist in the window
- Handle negative values in bucket ids
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
- What if t is a percentage of the bid rather than an absolute amount?
- Return the pair of indices, not just a boolean.
- How would you run this over a stream partitioned by advertiser?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
- Input: list of integer bids, window
k >= 0, tolerancet >= 0. - Output: True if there exist
i != jwith|i - j| <= kand|bids[i] - bids[j]| <= t....
High-Level Design
Ordered-set version. Slide a window holding the previous k bids in a balanced BST. For each new bid x, find the smallest value >= x - t; if it is <= x + t, return True. Insert x and evict the ...