Suppose there is a real time feed of stock prices, how do you calculate the average of a subset of it (say over the past week)?
This was an interview question. I can come up with an algorithm to do it in O(n^2), but the interviewer wanted an algorithm that was O(n).