array index starting from 0 or 1?
in the for loop i <=length isn't it?
If no please explain

On 9/19/10, Ashish Goel <[email protected]> wrote:
> this is google question
>
> take arrays before[] and after
>
> before[0]=1
> after[length-1]=1;
>
> for (int i=1; i<length;i++)
> {
>  before[i]=a[i]*before[i-1];
>  after[length-1-i]=a[length-1-i]*after[length-i];
> }
>
> now resuly for the asked index is after[index]*before[index]
>
>
> the idea here is that we should not be using division..
>
>
> additionally, you can improve it if any of the numbers is zero
>
>
>
>
>
>
> Best Regards
> Ashish Goel
> "Think positive and find fuel in failure"
> +919985813081
> +919966006652
>
>
> On Sun, Sep 19, 2010 at 8:18 PM, 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]<algogeeks%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>>
>
> --
> 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.
>
>

-- 
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.

Reply via email to