java.lang.Object
g0701_0800.s0713_subarray_product_less_than_k.Solution

public class Solution extends Object
713 - Subarray Product Less Than K.<p>Medium</p> <p>Given an array of integers <code>nums</code> and an integer <code>k</code>, return <em>the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than</em> <code>k</code>.</p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> nums = [10,5,2,6], k = 100</p> <p><strong>Output:</strong> 8</p> <p><strong>Explanation:</strong></p> <p>The 8 subarrays that have product less than 100 are:</p> <p>[10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]</p> <p>Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> nums = [1,2,3], k = 0</p> <p><strong>Output:</strong> 0</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= nums.length <= 3 * 10<sup>4</sup></code></li> <li><code>1 <= nums[i] <= 1000</code></li> <li><code>0 <= k <= 10<sup>6</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • numSubarrayProductLessThanK

      public int numSubarrayProductLessThanK(int[] nums, int k)