/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param nums int整型一维数组
* @return int整型一维数组
*/
function timesExceptSelf( nums ) {
// write code here
let left = new Array(nums.length).fill(1)
let right = new Array(nums.length).fill(1)
for(let i = 1; i < nums.length; i++){
left[i] = left[i -1] * nums[i -1]
}
for(let i = nums.length - 2; i >= -1; i--){
right[i] = right[i + 1] * nums[i + 1]
}
return nums.map((i, idx) => {
return left[idx] * right[idx]
})
}
module.exports = {
timesExceptSelf : timesExceptSelf
};