#C13505. Contiguous Subarray Product Less Than K
Contiguous Subarray Product Less Than K
Contiguous Subarray Product Less Than K
You are given an array of positive integers and a positive integer \( k \). Your task is to find the number of contiguous subarrays where the product of all the elements is strictly less than \( k \). This problem tests your ability to use the sliding window technique efficiently.
Example:
Input: [10, 5, 2, 6], k = 100 Output: 8</p>Explanation: The contiguous subarrays that have a product less than 100 are: [10], [5], [2], [6], [10,5], [5,2], [2,6].
Note: If \( k \) is less than or equal to 1, there will be no valid subarray because all numbers are at least 1.
inputFormat
The first line of input contains an integer \( n \) denoting the number of elements in the array.
The second line contains \( n \) space-separated positive integers representing the array.
The third line contains an integer \( k \).
outputFormat
Output a single integer, the number of contiguous subarrays where the product of all the elements is less than \( k \).
## sample4
10 5 2 6
100
8