Leetcode 713. Subarray Product Less Than K
Count the number of contiguous subarrays of positive integers whose product is strictly less than k. Because all nums > 0, this is a sliding-window/two-pointer problem maintaining a running product (with the quick edge case that k ≤ 1 yields 0).
Asked at:
Apple
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Mid December, 2025
Apple
Senior
Early December, 2025
Apple
Senior
You have an array nums and an integer k. Find the total number of contiguous subarrays where the product of all the elements in the subarray is less than k. Example 1: Input: `nums = [10, 5, 2, 6]`, `k = 100` Output: `8` Explanation: The subarrays that have a product less than 100 are : `[10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]`. Example 2: Input: `nums = [1, 2, 3]`, `k = 0` Output: `0` Explanation: No subarray's product is less than 0.
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.