Count subarrays with product under target | Bloomberg
|Home/Coding & Algorithms/Bloomberg
Count subarrays with product under target
Bloomberg
Sep 6, 2025, 12:00 AM
Software Engineer
Onsite
Coding & Algorithms
0
0
Given an array of positive integers nums and an integer T > 1, return the number of contiguous subarrays whose product is strictly less than T. Provide an algorithm that runs in O(n) time with O(
extra space beyond the input. Discuss edge cases such as T <= 1 and the presence of 1s in nums, and explain why your approach is correct.