Also, when using a greedy strategy, it is best when you can PROVE why the strategy works.
On Sun, Aug 7, 2011 at 10:25 PM, Gaurav Menghani <gaurav.mengh...@gmail.com>wrote: > O(n) solution is pretty simple, without using a greedy strategy. > > prod[i] denotes product of ith, i+1th and i+2th elements. > prod[i+1] is simply (prod[i]/arr[i])*(arr[(i+1)+2]). > > Answer would be the maximum product value. Do note that if prod[i] is zero, > do not use the above formula, instead simply multiply the ith, i+1th and > i+2th elements. > > On Sun, Aug 7, 2011 at 8:28 PM, Debabrata Das < > debabrata.barunhal...@gmail.com> wrote: > >> why do you need three smallest number, two would suffice ? >> >> >> On Sun, Aug 7, 2011 at 7:47 PM, Amol Sharma <amolsharm...@gmail.com>wrote: >> >>> yes...it should work !! >>> -- >>> >>> >>> Amol Sharma >>> Third Year Student >>> Computer Science and Engineering >>> MNNIT Allahabad >>> >>> >>> >>> >>> On Sun, Aug 7, 2011 at 7:13 PM, Prakash D <cegprak...@gmail.com> wrote: >>> >>>> 1 >>>> >>> >>> -- >>> 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. >> > > > > -- > Gaurav Menghani > -- Gaurav Menghani -- 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.