• 0

Given an array of numbers, return array of products of all other numbers

Problem

Given an array of n integers, return an array of same size such that prod[i] is equal to the product of all the elements of arr[] except arr[i].

Restrictions

 - Not allowed to use division operator

 - Max Time complexity should be O(n)

Example

data = [ 1, 2, 3, 4 ]
prod = [24, 12, 8, 6]

Solution