Count Ad Funnels Whose Step Multiplier Product Stays Below K
Last updated: November 29, 2026
Quick Overview
Given a list of positive per-step multipliers in an ad funnel and a threshold k, count the contiguous step ranges whose product is strictly less than k.
Meta
November 29, 20260
0
0 solved
Given a list of positive per-step multipliers in an ad funnel and a threshold k, count the contiguous step ranges whose product is strictly less than k.
A sliding window counting problem with a multiplicative twist, set in Meta's ads measurement domain. The interviewer checks that you can count windows (not just find one) by adding the window length at each right edge.
What the Interviewer Expects
- Uses a window whose product is kept below k by shrinking from the left
- Adds right - left + 1 to the count for each right edge
- Explains why every subarray ending at right inside the window is valid
- Handles k <= 1 as an immediate zero
- Mentions log-sum as an alternative for floating point stability
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Multipliers can be fractional (below 1). Does the window still work?
- Return the longest range with product below k.
- How would you avoid overflow in a language with fixed-width integers?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: mult, a list of positive integers, and k. Output: the number of pairs (i, j) with i <= j and mult[i] * ... * mult[j] < k. Length up to 3 * 10^4....
High-Level Design
Because all values are at least 1, extending a window never decreases its product and shrinking never increases it, which makes a two pointer window valid. For each right, multiply in mult[right],...