Product of Array Except Self

In this tutorial, I am going to discuss a very interesting problem Product of array except self or product of every integer except the integer at that index.

Given an array of N integers where N > 1. Write a code to print the result/output such that result[i] is equal to the product of all the elements of an array except self (result[i]).

For example –

Input: {4, 2, 1, 7}

Output: {14, 28, 56, 8}

NOTE: We have to solve this problem without division and in linear time O(n).