It's been discussed here before. Start by multiplying from either sides of the array and stop when both pointers reach the opposite side. takes O(n) time and does not involve division so won't crap out for cases where some of the elements are 0.
I was asked this for my Google phone screen I wish I knew this^ back then. On Sep 19, 7:48 am, bittu <[email protected]> wrote: > Given an array of numbers, replace each number with the product of > all the numbers in the array except the number itself *without* using > division. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
