Shortest Burst of Uploads Reaching a Storage Threshold

Last updated: November 29, 2026

Quick Overview

Given positive upload sizes in arrival order and a threshold T, return the length of the shortest contiguous burst whose total size is at least T, or 0 if no burst reaches it.

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

0

0

0 solved


Given positive upload sizes in arrival order and a threshold T, return the length of the shortest contiguous burst whose total size is at least T, or 0 if no burst reaches it.

A variable-size sliding window problem framed around Instagram upload pipelines. The interviewer checks that you see why positivity makes the window shrinkable and that you write the expand and shrink loop without off-by-one errors.

What the Interviewer Expects
  • Notes that all sizes are positive, which makes a two pointer window valid
  • Expands the right edge and shrinks the left while the sum still meets T
  • Updates the best length inside the shrink loop
  • Returns 0 when no window qualifies
  • Gives O(n) time and explains why each pointer moves at most n times
Key Topics to Cover
sliding window
two pointers
minimum length
positive values
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
  • Sizes can now be negative. What breaks and what replaces it?
  • Answer many thresholds for the same array efficiently.
  • Find the longest burst whose total stays at or below T.
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: sizes, a list of positive integers, and T > 0. Output: the minimum length of a subarray with sum >= T, or 0 if the whole array sums to less than T....

High-Level Design

Keep left and a running sum of sizes[left..right]. For each right, add its size. While the sum is at least T, the current window is a candidate, so record its length and then drop sizes[left] ...


Submit Your Answer
Markdown supported