Product of Array Except Self (Medium)
Problem Statement
Given an array of integers, return a new array where each element at index i
of the new array is the product of all the numbers in the original array except the one at i
. You must solve this problem without using division.
Example Generation

 Input:
[2, 3, 4, 5]
 Expected Output:
[60, 40, 30, 24]
 Justification: For the first element:
3*4*5 = 60
, for the second element:2*4*5 = 40
, for the third element:2*3*5 = 30
, and for the fourth element:2*3*4 = 24
.
 Input:

 Input:
[1, 1, 1, 1]
 Expected Output:
[1, 1, 1, 1]
 Justification: Every element is 1, so the product of all other numbers for each index is also 1.
 Input:

 Input:
[10, 20, 30, 40]
 Expected Output:
[24000, 12000, 8000, 6000]
 Justification: For the first element:
20*30*40 = 24000
, for the second element:10*30*40 = 12000
, for the third element:10*20*40 = 8000
, and for the fourth element:10*20*30 = 6000
.
 Input:
Try it yourself
Try solving this question here:
Python3
Python3
. . .