take 2 arrays before and after... before[i] contains the product of all the
numbers before i and after[i] contains product of all the numbers after i
something like this

    before[0]=1;
    after[n-1]=1;
    for(i=1;i<n;i++)
    {
        before[i]=a[i-1]*before[i-1];
        after[n-i-1]=after[n-i]*a[n-i];
    }
   for(i=0;i<n;i++)
    printf("%d\n",before[i]*after[i]);


On Sun, Jul 17, 2011 at 4:28 PM, geek forgeek <geekhori...@gmail.com> wrote:

> given an array a[0......n-1]  .required to find the output array out
> [0.........n-1] such that out [i] is the product of all the numbers a[0] to
> a[n-1] excluding a[i]
> for ex out[2]=a[0]*a[1]*a[3]*a[4]....a[n-1]
> constraint is not using division operator
>
> how to do this in O(n)??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com.
> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to