Update 66. 构建乘积数组.md

题目链接改为力扣中的对应题目,题目描述和代码按该题的接口调整。
This commit is contained in:
CyC2018
2026-10-28 13:45:07 +08:00
parent 6b83383821
commit 81cef9e578
+5 -5
View File
@@ -2,7 +2,7 @@
## 题目链接
[NowCoder](https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46?tpId=13&tqId=11204&tPage=1&rp=1&ru=/ta/coding-interviews&qru=/ta/coding-interviews/question-ranking&from=cyc_github)
[Leetcode](https://leetcode.cn/problems/gou-jian-cheng-ji-shu-zu-lcof/)
## 题目描述
@@ -14,12 +14,12 @@
## 解题思路
```java
public int[] multiply(int[] A) {
int n = A.length;
public int[] statisticalResult(int[] arrayA) {
int n = arrayA.length;
int[] B = new int[n];
for (int i = 0, product = 1; i < n; product *= A[i], i++) /* 从左往右累乘 */
for (int i = 0, product = 1; i < n; product *= arrayA[i], i++) /* 从左往右累乘 */
B[i] = product;
for (int i = n - 1, product = 1; i >= 0; product *= A[i], i--) /* 从右往左累乘 */
for (int i = n - 1, product = 1; i >= 0; product *= arrayA[i], i--) /* 从右往左累乘 */
B[i] *= product;
return B;
}