原题链接:https://leetcode-cn.com/problems/gou-jian-cheng-ji-shu-zu-lcof/
vector
<int> constructArr(vector
<int>& a
) {
int n
= a
.size();
if (n
== 0) return {};
vector
<int> b(n
, 0);
b
[0] = 1;
for (int i
= 1; i
< n
; i
++) b
[i
] = b
[i
- 1] * a
[i
- 1];
int t
= 1;
for (int i
= n
- 2; i
>= 0; i
--) {
t
*= a
[i
+ 1];
b
[i
] *= t
;
}
return b
;
}
转载请注明原文地址:https://blackberry.8miu.com/read-4971.html