Count Telemetry Windows Whose Error Deltas Sum to Target

Last updated: November 29, 2026

Quick Overview

Given an array of integer error-count deltas from Azure telemetry (values can be negative) and a target k, count the contiguous subarrays whose sum equals k.

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

0

0

0 solved


Given an array of integer error-count deltas from Azure telemetry (values can be negative) and a target k, count the contiguous subarrays whose sum equals k.

A common Microsoft onsite coding round problem dressed in Azure Monitor terms. Negative values break the sliding window approach, so the interviewer checks whether you reach for prefix sums with a hash map and can explain why two pointers fail.

What the Interviewer Expects
  • Explain why a sliding window does not work with negative numbers
  • Use running prefix sums
  • Store counts of prior prefix sums in a dictionary
  • Seed the map with prefix 0 seen once
  • Analyze O(n) time and space
Key Topics to Cover
prefix sums
hash maps
subarrays
negative numbers
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
  • How would you return the longest such window instead of the count?
  • What changes if you need sum at least k with only positive values?
  • How would you do this over a stream with bounded memory?
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 deltas (possibly negative or zero) and an integer k. Output: number of pairs (i, j) with i <= j such that deltas[i..j] sums to k. Counting overlapping windows is ex...

High-Level Design

Define P[j] as the sum of the first j elements. A window (i, j] sums to k exactly when P[j] - P[i] = k, that is P[i] = P[j] - k. Sweep left to right keeping the running prefix and a dictionary...


Submit Your Answer
Markdown supported