Databricks·Software Engineer·Technical Phone Screen
- Design an in-memory data structure with a record(timestamp) method and a getQPS(timestamp) method, where getQPS returns the average requests per second over the last 5 minutes ending at the given timestamp.
- How would you implement this using a sliding window approach?
- How would you reduce memory usage if you can't store every individual request timestamp, while still keeping performance reasonable?
“My first instinct was to just store every timestamp in a list and filter on getQPS.”