Stock Ticker

24717
Apr 26, 2016
Oct 23, 2018

Give a stream of stock prices, design a data structure to support the following operations:

  1. StockSticker(int k) Initialize the size of the ticker.
  2. void addOrUpdate(String stock, double price) add or update the price of a stock to the data structure.
  3. List<Map.Entry<String, double>> top() return the top k price stocks and their current prices.
Comments (18)