Tips

  • keep an output array
  • keep an initial product set to 1
  • the key is to push to the output before generating a new product value. this way, you can avoid pushing an item to the output array that is a product of itself
  • loop right to get the product right of the initial element. loop left to get the product left of the initial element

Solution 1

Solution 2

References