Similar second solution:

class Solution { public: int numSubarrayProductLessThanK(vector<int>& nums, int k) { int size = nums.size(); int product = 1; int right = 0; int result = 0; for (int i = 0; i < size; i++) { if (right < i) { right = i; product = 1; } while (right < size && product * nums[right] < k) product *= nums[right++]; result += right - i; product /= nums[i]; } return result; } };Subarray Product Less Than K