You are asked to design an auction system that manages bids from multiple users in real time.
Each bid is associated with a userId, an itemId, and a bidAmount.
Implement the AuctionSystem class:
AuctionSystem(): Initializes the AuctionSystem object.
void addBid(int userId, int itemId, int bidAmount): Adds a new bid for itemId by userId with bidAmount. If the same userIdalready has a bid on itemId, replace it with the new bidAmount.
void updateBid(int userId, int itemId, int newAmount): Updates the existing bid of userId for itemId to newAmount. It is guaranteed that this bid exists.
void removeBid(int userId, int itemId): Removes the bid of userId for itemId. It is guaranteed that this bid exists.
int getHighestBidder(int itemId): Returns the userId of the highest bidder for itemId. If multiple users have the same highestbidAmount, return the user with the highestuserId. If no bids exist for the item, return -1.
/** * Your AuctionSystem object will be instantiated and called as such: * AuctionSystem* obj = new AuctionSystem(); * obj->addBid(userId,itemId,bidAmount); * obj->updateBid(userId,itemId,newAmount); * obj->removeBid(userId,itemId); * int param_4 = obj->getHighestBidder(itemId); */