Skip to content

Commit ad5eb61

Browse files
authored
Update 713._Subarray_Product_Less_Than_K.md
1 parent 1175557 commit ad5eb61

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

docs/Leetcode_Solutions/713._Subarray_Product_Less_Than_K.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ class Solution(object):
6464
> 思路 2
6565
******- 时间复杂度: O(N)******- 空间复杂度: O(1)******
6666

67-
``
67+
参考[gabbu](https://leetcode.com/problems/subarray-product-less-than-k/discuss/108846/Python-solution-with-detailed-explanation)
68+
```
6869
Initialize start and end to index 0. Initialize prod to 1. Iterate end from 0 to len(nums)-1.
6970
Now if prod * nums[end] is less than k, then all subarray between start and end contribute to the solution.
7071
Since we are moving from left to right, we would have already counted all valid subarrays from start to end-1.
7172
How many new subarrays with nums[end]? Answer: end-start. What will be the updated prod? Answer: prod * nums[end].
73+
7274
```
7375

7476
```python

0 commit comments

Comments
 (0)