Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!
@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]=216 after[0]=864 ans[0]= ( before[0]=1 )*(after[0]=864) . . . similarly others - Naveen -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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.
Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!
Thanks for clearing On Tue, Sep 21, 2010 at 1:58 PM, Naveen Agrawal nav.coo...@gmail.comwrote: @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]=216 after[0]=864 ans[0]= ( before[0]=1 )*(after[0]=864) . . . similarly others - Naveen -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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.
[algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!
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 shashank7andr...@gmail.com 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 algoge...@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.
Re: [algogeeks] Re: Array Good One!!!!!!!!!!!!!!!!!!!!!!
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 PM, Minotauraus anike...@gmail.com wrote: 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 shashank7andr...@gmail.com 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@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 algoge...@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.