In careercup.com, I have seen a problem. It basically asks to get an integer array(includes positives and negatives) and return maximum positive product of three distinct element in it. Sorting is not allowed. For example: arr = [9, 10, -12, 4, 7, -8, -13, 4, -8, 12] elements = (-13, -12, 12) There are two cases: either P1*P2*P3 or N1*N2*P1(Pi stands for ith biggest and Ni stands for ith smalltest number.). So, the algorithm finds 2 elements in the array by partitioning. One is the 2nd smallest and the other is 3rd biggest number. Then, among biggest 2 element, it finds the maximum. The latest form of array is as follows: N1,N2,...........,P3,P2,P1 It compares N1*N2 ith. P3*P2. It returns elements of bigger one with P1.
Development of cutting-edge technologies