Subarrays With Product Below K

Medium · rating 1500 · Sliding Window, Two Pointers

The first line has n and k. The second line has n positive integers. Print the number of contiguous subarrays whose product is strictly less than k.

Constraints: 1 ≤ n ≤ 105, 1 ≤ k ≤ 109

Related problems

Open Subarrays With Product Below K in Code Arena →