Implement a RunningCommodityPrice class that tracks the maximum price.
Unlock detailed company stats for this questionUpgrade
Stream of events that either add or update a price against a timestamp. Interface: void upsertCommodityPrice(int timestamp, int commodityPrice); int getMaxCommodityPrice(). Example: upsert(4, 27), upsert(6, 26), upsert(9, 25); getMax() returns 27 (timestamp 4). Then upsert(4, 28) updates the price at timestamp 4, so getMax() returns 28. Timestamps can come out of order and there can be duplicates.
Community answers
No answers contributed by the community yet.
Related courses

Course

Course
Course
