Simulate Auction Clock With Bid Extensions And Sudden Death

Last updated: November 29, 2026

Quick Overview

An auction starts at a price and ends at a given time; a valid bid placed within the final window seconds pushes the end to bid time plus the window, unless the auction is in sudden death mode where the clock never extends. Given the bid stream, return the winner, final price, and actual end time.

Whatnot
Coding & Algorithms
Software Engineer
Whatnot
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


An auction starts at a price and ends at a given time; a valid bid placed within the final window seconds pushes the end to bid time plus the window, unless the auction is in sudden death mode where the clock never extends. Given the bid stream, return the winner, final price, and actual end time.

Whatnot sellers can choose standard auctions that extend on late bids or sudden death auctions where the timer is final, so the clock logic is core product behavior. Interviewers look for a clean state machine and careful handling of when the auction is closed.

What the Interviewer Expects
  • Model state as price, leader, and current end time
  • Stop processing once a bid arrives after the current end
  • Extend only when the remaining time is less than the window
  • Ignore bids that do not beat the price and self-outbids by the leader
  • Explain why sudden death is just a flag on the same loop
Key Topics to Cover
simulation
state machine
timers
auction rules
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
  • How do you handle clock skew between the client that placed the bid and the server?
  • What if the server receives bids slightly out of order by a few milliseconds?
  • How would you cap the total number of extensions?
  • How would you test this logic deterministically?
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

Inputs: start_price, end_time, window, a list of (ts, bidder, amount), and sudden_death. A bid is valid if ts <= end, the amount strictly beats the current price, and the bidder is not alr...

High-Level Design

This is a small state machine with states OPEN and CLOSED. Bids are processed in time order. The only transition to CLOSED is a bid arriving after end, at which point no later bid can matter because...


Submit Your Answer
Markdown supported

Related Questions