Leetcode Problem 2034. Stock Price Fluctuation

2034. Stock Price Fluctuation

Leetcode Solutions

Approach: Hashed and Sorted Map

  1. Initialize latestTime, timestampPriceMap, and priceFrequency.
  2. In update, adjust latestTime if necessary, update timestampPriceMap, and adjust priceFrequency.
  3. In current, return the price at latestTime from timestampPriceMap.
  4. In maximum, return the last key from priceFrequency.
  5. In minimum, return the first key from priceFrequency.
UML Thumbnail

Approach: Hashmap and Heaps

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...