Lowest-Bid Auction System
Problem statement
Build an auction system where the lowest bid is the best bid. Process a list of operations in order. operations[i] is the name of operation i, and args[i] holds its integer arguments.
"bid"with arguments[auctionId, amount]: place a bid ofamounton auctionauctionId. An auction opens the first time it receives a bid. A bid on an auction that was removed is ignored."lowest"with no arguments: report the lowest bid amount among all bids on auctions that have not been removed, or-1if there is no such bid. This operation does not change anything."remove"with arguments[auctionId]: remove auctionauctionId. Its bids stop counting, and every later bid on it is ignored. Removing an auction that has no bids or was already removed still marks it as removed and does nothing else.
Return an array with one value for each "lowest" operation, in order.
The problem statement continues
ProExamples
Example 1
operations = ["bid","bid","bid","lowest","remove","lowest","bid","lowest"]args = [[1,50],[2,30],[1,40],[],[2],[],[2,10],[]]return = [30,40,40]- After three bids, the amounts are
50and40on auction1and30on auction2, so the first query reports30. - Removing auction
2drops its bid, so the second query reports40. - The bid of
10on removed auction2is ignored, so the last query still reports40.
FastPrep Pro
Reported in 1 Google interview this weekUnlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$8.25/month
$99 billed yearly — or $19 month-to-month. Cancel anytime.
Free plan — 2 of 2 free unlocks used this week