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
Coding & Algorithms
Software Engineer
Meta
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

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
sliding window
ordered set
bucketing
hash map
integrity signals
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. 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 Problems
Sample Answer
Requirements
  • Input: list of integer bids, window k >= 0, tolerance t >= 0.
  • Output: True if there exist i != j with |i - j| <= k and |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 ...


Submit Your Answer
Markdown supported