题解 | #构建乘积数组#
构建乘积数组
https://www.nowcoder.com/practice/94a4d381a68b47b7a8bed86f2975db46
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param A int整型一维数组
* @return int整型一维数组
*/
function multiply( A ) {
const B = [];
for(let i = 0; i < A.length; i++){
let temp = 1;
for(let j = 0; j < A.length; j++){
if(j !== i){
temp *= A[j];
B[i] = temp;
}
}
}
return B;
}
module.exports = {
multiply : multiply
};
