Count Product Bundles Whose Price Multiplier Stays Under a Cap

Last updated: November 29, 2026

Quick Overview

Given positive discount multipliers for consecutive items in a promotion lineup and a cap k, count the contiguous bundles whose product of multipliers is strictly less than k.

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

0

0

0 solved


Given positive discount multipliers for consecutive items in a promotion lineup and a cap k, count the contiguous bundles whose product of multipliers is strictly less than k.

An Amazon onsite question in a pricing context, where bundles stack multiplicative fees. The interviewer looks for a sliding window over products that counts all windows ending at each right edge, and for clean handling of k <= 1.

What the Interviewer Expects
  • Use a sliding window with a running product
  • Divide out the leftmost item while the product is at least k
  • Add right - left + 1 windows per step
  • Handle k <= 1 up front
  • Discuss log-sum alternatives for overflow
Key Topics to Cover
Sliding Window
Counting Subarrays
Two Pointers
Arrays
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 multipliers can be fractional values like 0.8?
  • List the bundles instead of counting them; what is the output bound?
  • How would you count bundles with product exactly equal to k?
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 nums of positive integers, integer k. Output: number of contiguous subarrays with product strictly less than k....

High-Level Design

With positive integers, extending a window never decreases its product, so for each right edge there is a smallest valid left edge, and it only moves forward. Keep the running product of `nums[left..r...


Submit Your Answer
Markdown supported