Flag Slow Annotation Tasks Using a Rolling Median of Durations
Last updated: November 29, 2026
Quick Overview
Given a stream of task completion durations for one contributor, flag index i when its duration is more than factor times the median of the previous k durations. Achieve O(log k) per update rather than resorting each window.
Turing
November 29, 20260
0
0 solved
Given a stream of task completion durations for one contributor, flag index i when its duration is more than factor times the median of the previous k durations. Achieve O(log k) per update rather than resorting each window.
Turing runs large human data pipelines where task timing signals both quality problems and pay fairness, and a rolling median is robust to the occasional outlier. Onsite, the interviewer is checking whether the candidate can build and debug a two-heap structure with lazy deletion, which is easy to get subtly wrong.
What the Interviewer Expects
- Explains why median beats mean for skewed task durations
- Uses two heaps with balanced valid sizes
- Implements lazy deletion with a pending-removal map
- Prunes heap tops after removals and rebalances
- Validates against a brute-force version
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you compute this across 50,000 contributors in a streaming system?
- How would you replace the exact median with an approximate quantile sketch?
- Is a fixed factor fair across task types with very different lengths?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: list durations, window size k, multiplier factor. For each i >= k, compare durations[i] with the median of durations[i-k:i] (the previous k, excluding i). Return flagged indexes. Ta...
High-Level Design
Keep a max-heap lo holding the smaller half and a min-heap hi for the larger half, with lo having equal or one more valid element. The median is the top of lo or the average of both tops. Pyth...