mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
29 lines
954 B
HTML
29 lines
954 B
HTML
<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> </p>
|
|
<p><strong>Example 1:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> nums = [10,5,2,6], k = 100
|
|
<strong>Output:</strong> 8
|
|
<strong>Explanation:</strong> The 8 subarrays that have product less than 100 are:
|
|
[10], [5], [2], [6], [10, 5], [5, 2], [2, 6], [5, 2, 6]
|
|
Note that [10, 5, 2] is not included as the product of 100 is not strictly less than k.
|
|
</pre>
|
|
|
|
<p><strong>Example 2:</strong></p>
|
|
|
|
<pre>
|
|
<strong>Input:</strong> nums = [1,2,3], k = 0
|
|
<strong>Output:</strong> 0
|
|
</pre>
|
|
|
|
<p> </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>
|