By syam1224
via linkmingle.com
Published: Jun 05 2008 / 13:13
There is an array A[N+1] of N integers. You have to compose an array Output[N+1] such that Output[i] will be equal to the productof all the elements of A[] except A[i].
Example:
INPUT:[4, 3, 2, 1, 2]
OUTPUT:[12, 16, 24, 48, 24]
Solve it without division operator and in O(n).
Comments
raveman replied ago:
Its hard to vote on this one, good question and bad answer(i dont even try to understand how it works). You can write it better with nested foreach.
However knowing Google they might like this answer better, they are bored.
Voters For This Link (14)
Voters Against This Link (0)