This is the array in which except self element product of remaining elements product are stored in the index of self element.

Example:

Input: arr[]  = {10, 3, 5, 6, 2}

Output: prod[]  = {180, 600, 360, 300, 900}

There is a code to solve the problem:

  1. In this ,firstly we have to take 3 arrays pre[] ,post[] and result[] of size of the given array.

2. In the pre[] array, stores the product of elements from the left side ,and in the post[] array ,stores the product of elements from the right side of an array.

3. Then,updates the values of resulting array result[0] = post[1] and result[n-1] = pre[n-2].

4. Then , update the result array using for loop(i->1 to n-1),and result[i] = pre[i-1]*post[i+1];

5. Then ,print the array.

Output:

Note:-Time Complexity of this approach is O(n), where n is the number of elements in the array , but this method take a lot of memory.