Count Latency Windows Whose Product Stays Below a Risk Limit

Last updated: November 29, 2026

Quick Overview

Given positive per-hop slowdown factors along a request path and a limit, count the contiguous segments whose product of factors is strictly less than the limit.

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

0

0

0 solved


Given positive per-hop slowdown factors along a request path and a limit, count the contiguous segments whose product of factors is strictly less than the limit.

A Google technical-screen counting variant of the sliding window, framed around multiplicative slowdowns across service hops. The interviewer checks that the candidate counts all valid subarrays ending at each right edge rather than enumerating them, and handles limits of 1 or less.

What the Interviewer Expects
  • Maintains the product of the current window
  • Shrinks while the product reaches the limit
  • Adds `right - left + 1` subarrays per step
  • Handles `limit <= 1` as a special case
  • Mentions logs to avoid overflow with floats
Key Topics to Cover
Sliding Window
Counting Subarrays
Two Pointers
Products
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 handle factors that can be less than 1?
  • What if you need the count of segments with product exactly equal to the limit?
  • How would you avoid overflow in a fixed-width language?
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 factors of positive integers, integer limit.
  • Output: number of contiguous sublists with product < limit.
  • Because every factor is at least 1, extending a window never decreases ...
High-Level Design

For each right, find the smallest left such that the product of factors[left..right] is below the limit. Every sublist that ends at right and starts anywhere in [left, right] is also below t...


Submit Your Answer
Markdown supported