Subarray Product Less Than K
Apple interview questions · Medium · Coding round · 7 tests
Count the contiguous subarrays of the integer array nums whose elements multiply
to a value that is strictly less than the integer k, and return
that count.
Examples
numSubarrayProductLessThanK([10, 5, 2, 6], 100) // 8
// Length 1: [10], [5], [2], [6]
// Length 2: [10, 5], [5, 2], [2, 6]
// Length 3: only [5, 2, 6]; [10, 5, 2] is left out since 10 * 5 * 2 equals 100, which is not below k.Run your code with Ctrl+Enter to see results.