Shortest Telemetry Burst Whose Net Byte Delta Reaches a Threshold

Last updated: November 29, 2026

Quick Overview

A network telemetry stream records signed byte deltas per interval (positive for growth, negative for drain). Return the length of the shortest contiguous run whose sum is at least `threshold`, or -1 if none exists.

Microsoft
Coding & Algorithms
Software Engineer
Microsoft
November 29, 2026
Software Engineer
Onsite
Coding & Algorithms
Hard

0

0

0 solved


A network telemetry stream records signed byte deltas per interval (positive for growth, negative for drain). Return the length of the shortest contiguous run whose sum is at least `threshold`, or -1 if none exists.

Microsoft onsite rounds use this to see whether candidates notice that negative values break the usual two pointer window. The interviewer expects prefix sums plus a monotonic deque and a clear argument for both pop rules.

What the Interviewer Expects
  • Explain why the sliding window fails when values can be negative
  • Convert to prefix sums: find j > i with P[j] - P[i] >= threshold and smallest j - i
  • Maintain a deque of start indices with increasing prefix values
  • Justify popping from the front (answer found, can never be shorter) and from the back (dominated start)
  • Reach O(n)
Key Topics to Cover
monotonic deque
prefix sums
subarray sums
sliding window
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 you want the count of such runs instead of the shortest?
  • How would you handle a stream where you only keep the last W intervals?
  • What if all values are known to be positive?
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 of integers (may be negative) and a threshold.
  • Output: smallest length of a contiguous subarray with sum at least threshold, or -1.
  • Clarify that the threshold is positive in typical ...
High-Level Design

Let P[k] be the sum of the first k deltas. A run from i to j - 1 qualifies when P[j] - P[i] >= threshold. For each end j we want the latest start i that still qualifies.

Keep a deque of candidate...


Submit Your Answer
Markdown supported