Skip to content

Commit ba83b3a

Browse files
authored
Update 238.product-of-array-except-self.md
1 parent 5501460 commit ba83b3a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

problems/238.product-of-array-except-self.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Could you solve it with constant space complexity? (The output array does not co
2222
## 思路
2323

2424
这道题的意思是给定一个数组,返回一个新的数组,这个数组每一项都是其他项的乘积。
25-
符合直觉的思路是两层循环,时间复杂度是O(n),但是题目要求`Please solve it without division and in O(n)`
25+
符合直觉的思路是两层循环,时间复杂度是O(n^2),但是题目要求`Please solve it without division and in O(n)`
2626

2727
因此我们需要换一种思路,由于输出的每一项都需要用到别的元素,因此一次遍历是绝对不行的。
2828
考虑我们先进行一次遍历, 然后维护一个数组,第i项代表前i个元素(不包括i)的乘积。

0 commit comments

Comments
 (0)