re: Daily Coding Problem #2 VIEW POST

FULL DISCUSSION
 

Here's my TypeScript version.

This approach works in O(n) by dividing the product of all elements by x[i].

function uberMultiply(x: Array<number>) {
  const product = x.reduce( (a,b) => a * b );
  return x.map(v => product / v);
}
code of conduct - report abuse