← 返回 atlassian 的题目列表Design DataStructure for Price with Timestamp
类型:online_judge
atlassian
Design a data structure to support the following operations:
insert(String timestamp, int price): Insert a record with a timestamp and price.
getMaxPrice() -> int: Return the maximum price from the current data.
Requirement: Design an efficient data structure to support both operations quickly.
Test Cases:
Insert ('20231010', 100), max price should be 100.
Insert ('20231011', 200), max price should be 200.
Insert ('20231012', 150), max price should still be 200.
Insert ('20231013', 250), max price should be 250.
Assuming:
The timestamp is unique.
Example
Input
insert(20231010, 100)
getMaxPrice()