Very easy understand java solution


  • 0
    S

    public int numSubarrayProductLessThanK(int[] nums, int k) {
    int count = 0;
    for(int i = 0; i<nums.length; i++){
    int product = 1;
    int j = i;
    while(product < k && j<nums.length){
    product = product * nums[j];
    if(product < k) count++;
    j++;
    }
    }
    return count;
    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.