首页 > 代码库 > Get average stock price every 10 minutes
Get average stock price every 10 minutes
Write a class that displays average of stock prices for a given stock symbol for the last 10 minutes. We have a service that sends stock updates about 5000 times per second. The structure of the message is :
Message {
long timestamp;
String symbol; // E.g. AAPL
double price;
}
Idea: Use a buffer that has the capacity of 5000 * 60 * 10 messages. Then insert all the messages in to this buffer if the buffer has extra capacity. if the buffer is full, remove from the head and insert new messages from the tail. When the get average price is called, we calculate all the messages in this buffer.
Get average stock price every 10 minutes
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。