Shortest Burst of Requests Whose Bytes Reach a Bandwidth Quota

Last updated: November 29, 2026

Quick Overview

Given positive byte counts for consecutive requests and a quota, return the length of the shortest contiguous burst whose total bytes are at least the quota, or 0 if none exists.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Phone Screen
Coding & Algorithms
Medium

0

0

0 solved


Given positive byte counts for consecutive requests and a quota, return the length of the shortest contiguous burst whose total bytes are at least the quota, or 0 if none exists.

Framed around detecting quota exhaustion on a Google Cloud load balancer, this tests a shrinking sliding window that relies on all values being positive. The interviewer then asks what breaks when values can be negative, which leads to a different technique.

What the Interviewer Expects
  • Uses a window that expands right and shrinks left while the sum is large enough
  • Relies explicitly on positivity for correctness
  • Returns 0 when no burst reaches the quota
  • Mentions the O(n log n) prefix-sum plus binary search alternative
  • Explains why negatives break this approach
Key Topics to Cover
Sliding Window
Two Pointers
Prefix Sums
Positivity
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if some values can be negative (refunds or corrections)?
  • Return the start index of the earliest shortest burst.
  • How would you report this continuously on a live stream?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list sizes of positive integers, integer quota > 0.
  • Output: the minimum length of a contiguous block with sum at least quota, or 0....
High-Level Design

Expand right and add sizes[right] to the running sum. As long as the sum is at least the quota, the current window is valid: record its length and then drop sizes[left] to try a shorter one. Bec...


Submit Your Answer
Markdown supported