Efficient Simple Moving Average - Quant Trader Interview Question
Difficulty: Easy
Category: Number Theory & Algorithms
Practice quant interview questions from top firms including Jane Street, Citadel, Two Sigma, DE Shaw, and other leading quantitative finance companies.
Topics: data-structures, algorithms, sma, time-complexity
Problem Description
You are building a high-frequency trading system and need to calculate a Simple Moving Average (SMA) of the last $N$ prices efficiently. The system receives a continuous stream of price data and each new price must update the SMA in $O(1)$ time.
Which data structure, along with a running sum, allows for an update time complexity of $O(1)$ for each new price update to the SMA?
Practice this easy trader interview question on MyntBit - the all-in-one quant learning platform with 200+ quant interview questions for Jane Street, Citadel, Two Sigma, and other top quantitative finance firms.