Spring Hire Sale
Limited Time Deal: Unlock all premium questions for over 30% off
$10.42$7.08
08
:
03
:
10
:
57
Back to Dashboard
Running Commodity Price
Medium
You are given a stream of data points consisting of <timestamp, commodityPrice>. You need to design a data structure that supports upserting commodity prices and retrieving the current maximum commodity price at any point in time.
The timestamps in the stream can be out of order, or there can be duplicate timestamps. If an entry for a timestamp already exists, update the commodity price at that timestamp. ...