Easiest Java O(nlogn) Solution


#1

public class Solution {
public int maxp3(int[] A) {

    if(A.length < 3)
        return 0;
    Arrays.sort(A);
    
    int prod_1 = A[0]*A[1]*A[A.length-1];
    int prod_2 = A[A.length-1]*A[A.length-2]*A[A.length-3];
    
    return Math.max(prod_1,prod_2);
}

}


#2

Wrong. Try on [-100, -50, 1, 2, 3, 50]