The Event Aggregator
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
Given a list of event dicts (each with 'timestamp' and 'value') and an integer bucket_width, group events into buckets where each bucket covers timestamps in [bucket_start, bucket_start + bucket_width). For each bucket with at least one event, return a dict with 'bucket_start', 'count', 'total' (sum of values). Sort the output by bucket_start ascending.
Summary
Bucket a firehose of events into tidy time windows.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.