#3815
Design Auction System
specialist · 995 · lc medium +32 · 41.9% accepted · 79 likes · top 23%
Description
Design a real-time bidding platform where each bid records a userId, an itemId, and a bidAmount. Implement AuctionSystem() with: addBid(userId, itemId, bidAmount) — place or overwrite a bid; updateBid(userId, itemId, newAmount) — change an existing bid (guaranteed to exist); removeBid(userId, itemId) — delete a bid (guaranteed to exist); getHighestBidder(itemId) — return the userId with the highest bid, breaking ties by largest userId, or -1 if no bids.
Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24