Link Details

Link 85218 thumbnail
User 292570 avatar

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).
  • 14
  • 0
  • 2018
  • 789

Comments

Add your comment
User 191349 avatar

raveman replied ago:

0 votes Vote down Vote up Reply

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.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.