Description
Submission
class Solution { public: int numSubarrayProductLessThanK(vector<int>& nums, int k) { vector<int> product(nums.size()); product[0] = nums[0]; int counter = nums[0] >= k ? 0 : 1; int beg = 0; for(int i = 1; i < nums.size(); ++i) { for(product[i] = product[i-1] * nums[i]; product[i] >= k && beg <= i; product[i] /= nums[beg++]); counter += i - beg + 1; } return counter; } };