413. Subarray Product Less Than K
MediumSliding Window
All numbers are positive. Count the contiguous subarrays whose product is strictly less than k.
Input format
Line 1: n k Line 2: n positive integers
Output format
The count.
Example 1
Input
4 100 10 5 2 6
Output
8
Example 2
Input
3 0 1 2 3
Output
0
Constraints
1 ≤ n ≤ 10⁵ 0 ≤ k ≤ 10⁶
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…