The Firehose
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
You're rolling up a stream of metric events, each carrying a numeric `timestamp` and a numeric `value`, into fixed-width time windows of size `bucket_width`, where a window spans `[bucket_start, bucket_start + bucket_width)`. Collapse the events so every window holding at least one of them reports its event `count`, the `total` of its values, and the `bucket_start` it begins at. The events arrive in no particular order, any window that caught nothing is left out entirely, and the windows come back from earliest to latest.
Summary
A stream arrives out of order. Roll it up, one time window at a time.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.