Plan Adaptive Bitrates Over a Bandwidth Forecast Without Rebuffering
Last updated: November 29, 2026
Quick Overview
Given bitrate levels with quality scores, a per-segment bandwidth forecast, segment length, starting buffer and maximum buffer, choose a bitrate for every segment so the buffer never empties mid-download, maximizing total quality minus a penalty for quality switches.
Roku
November 29, 20260
0
0 solved
Given bitrate levels with quality scores, a per-segment bandwidth forecast, segment length, starting buffer and maximum buffer, choose a bitrate for every segment so the buffer never empties mid-download, maximizing total quality minus a penalty for quality switches.
Playback quality is a headline metric for Roku devices and the engineering team works on adaptive bitrate selection. This hard onsite problem checks whether you can model buffer dynamics as DP state, handle the buffer cap and the rebuffer constraint, and keep the state space bounded.
What the Interviewer Expects
- Models download time as bitrate x segment_seconds / bandwidth
- Defines state as (segment, last level, buffer) and explains why the last level is needed
- Discretizes buffer to keep states finite and rounds download time up to stay safe
- Applies the buffer cap and rejects any choice that would stall
- Reconstructs the plan and returns a clear signal when every plan stalls
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 does this offline plan relate to an online controller such as model predictive control over the next few segments?
- How would you account for forecast uncertainty?
- What changes if startup delay is also penalized?
- How would a learned policy (for example reinforcement learning) be evaluated against this baseline?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: bitrates[k] in kbps with quality[k], forecast bandwidth[i] kbps for segment i, segment length D, starting buffer B0, buffer cap Bmax. Downloading segment i at level k takes `bitrat...
High-Level Design
Greedy fails: taking top quality early can drain the buffer before a bandwidth dip. Use DP over segments with state (last_level, buffer). Buffer is continuous, so discretize to 0.1 second units and ...