We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1175557 commit ad5eb61Copy full SHA for ad5eb61
docs/Leetcode_Solutions/713._Subarray_Product_Less_Than_K.md
@@ -64,11 +64,13 @@ class Solution(object):
64
> 思路 2
65
******- 时间复杂度: O(N)******- 空间复杂度: O(1)******
66
67
-``
+参考[gabbu](https://leetcode.com/problems/subarray-product-less-than-k/discuss/108846/Python-solution-with-detailed-explanation)
68
+```
69
Initialize start and end to index 0. Initialize prod to 1. Iterate end from 0 to len(nums)-1.
70
Now if prod * nums[end] is less than k, then all subarray between start and end contribute to the solution.
71
Since we are moving from left to right, we would have already counted all valid subarrays from start to end-1.
72
How many new subarrays with nums[end]? Answer: end-start. What will be the updated prod? Answer: prod * nums[end].
73
+
74
```
75
76
```python
0 commit comments