@Coder: What if the data are -6, -5, -4, and -3. Then the largest product is (-5)*(-4)*(-3) = -60. The number with largest absolute value, -6, doesn't enter into the solution.
Dave On Aug 7, 1:19 pm, coder dumca <[email protected]> wrote: > 1: choose 4 biggest numbers with abs value > following situations will arise > 1: all 4 numbers are +ve then choose the biggest 3 > 2: 1 -ve 3 +ve choose 3 positive numbers > 3: 3 -ve 1 +ve choose 2 -ve(with largest abs value) and 1 +ve > 4: 2 +ve 2 -ve choose accordingly > 4 all are -ve choose 2 -ve(with largest abs value) and scna the arry to > finf largest +ve int > > pls let me know if i m wrong > > > > On Sun, Aug 7, 2011 at 6:09 AM, Nikhil Veliath <[email protected]> wrote: > > given an array that has n nos . . . . find the maximum product of 3 > > nos and display the 3 nos . . . > > > 25 9 6 8 -20 -5 -10 > > > so > > max product 5000 > > > the nos are -20 -10 25 > > > give an O(n) solution and if possible try avoid using sort > > > -- > > 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.
