classSolution{publicintnumSubarrayProductLessThanK(int[] nums,int k){int len = nums.length;int begin =0;int end =0;int mul =1;int count =0;while(begin < len){
mul =1;while(mul < k && end < len){
mul *= nums[end];if(mul < k){
count++;}
end++;}
begin++;
end = begin;}return count;}}
classSolution{publicintnumSubarrayProductLessThanK(int[] nums,int k){int n = nums.length, ret =0;int prod =1, i =0;for(int j =0; j < n; j++){
prod *= nums[j];while(i <= j && prod >= k){
prod /= nums[i];
i++;}
ret += j - i +1;}return ret;}}