Product array puzzle

Given an array of integers A, find and return the product array of same size where
i’th eement of the product array will be equal to the product of all the elements divided by the i’th element of the array.

Note: It is always possible to form the product array with integer (32 bit) values.



Input Format

The only argument given is the integer array A.

Output Format

Return the product array.

Constraints

1 <= length of the array <= 1000
1 <= A[i] <= 10

For Example

Input 1:
    A = [1, 2, 3, 4, 5]
Output 1:
    [120, 60, 40, 30, 24]

Input 2:
    A = [5, 1, 10, 1]
Output 2:
    [10, 50, 5, 50]
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Product array puzzle on Interview Code Editor
Hints
  • Hints are not available for this problem

Discussion


Loading...
Click here to start solving coding interview questions