Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!

2010-09-21 Thread kartheek muthyala
Thanks for clearing On Tue, Sep 21, 2010 at 1:58 PM, Naveen Agrawal wrote: > > @Kartheek > > Ashish algo is perfectly workingBy making before[0]&after[length-1]=1 > the array is shifted ,which prevents the inclusion of current index. > > Ex: > > int a[5]={10,4,8,3,9} > > before[0]=1 > bef

Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!

2010-09-21 Thread Naveen Agrawal
@Kartheek Ashish algo is perfectly workingBy making before[0]&after[length-1]=1 the array is shifted ,which prevents the inclusion of current index. Ex: int a[5]={10,4,8,3,9} before[0]=1 before[1]=10 before[2]=40 before[3]=320 before[4]=960 after[4]=1 after[3]=9 after[2]=27 after[1]=21

Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!

2010-09-19 Thread kartheek muthyala
I guess before[index] should contain product of the numbers before index and after[index] should contain all the product after the index but @Ashish algo isn't that before[index] contains product that includes the number at the index position also. Please clarify me... On Sun, Sep 19, 2010 at 9:27

[algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!

2010-09-19 Thread Minotauraus
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