dsa · medium

Stock Price Fluctuation

GreyOrangeHash MapHeapDesign

StockPrice: update(timestamp, price) (later update of the same ts overwrites), current = latest timestamp’s price, maximum, minimum among *current* prices.

Fill in the StockPrice class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.

**Example**

`` StockPrice() → null update(1, 10) → null update(2, 5) → null current() → 5 maximum() → 10 update(1, 3) → null maximum() → 5 update(4, 2) → null minimum() → 2 ``

Constraints

Calls <= 1000

Examples

Example 1

Input:
["StockPrice","update","update","current","maximum","update","maximum","update","minimum"]
[[],[1,10],[2,5],[],[],[1,3],[],[4,2],[]]

Expected:
[null,null,null,5,10,null,5,null,2]

Open in the Dojo editor