Open fly0o0 opened 4 years ago
/**
* @param {number[]} a
* @return {number[]}
*/
var constructArr = function(a) {
let n = a.length
let left = 1
let ret = []
for (let i = 0; i < n; i++) {
ret[i] = left
left *= a[i]
}
let right = 1
for (let j = n - 1; j >= 0; j--) {
ret[j] *= right
right *= a[j]
}
return ret
};