Popular Posts

Tuesday, March 15, 2011

A Product Array Puzzle

There is an array A[N] of N numbers. You have to compose an array Output[N] such that Output[i] will be equal to multiplication of all the elements of A[N] except A[i]. For example Output[0] will be multiplication of A[1] to A[N-1] and Output[1] will be multiplication of A[0] and from A[2] to A[N-1]. Solve it without division operator and in O(n).

Example:
A: {4, 3, 2, 1, 2}

OUTPUT: {12, 16, 24, 48, 24}
Refer :
http://www.ihas1337code.com/2010/04/multiplication-of-numbers.html

http://www.geeksforgeeks.org/archives/7527 

No comments:

Post a Comment