Simple Java Solution O(1)

programming
Tags: #<Tag:0x00007f2426f18320>

#1

public class Solution {
public int maxp3(ArrayList A) {
int max;

    A.sort(Collections.reverseOrder());
    
    int len = A.size();
    
    return Math.max(A.get(0)*A.get(1)* A.get(2), A.get(0)*A.get(len-1)*A.get(len-2));
}

}


#2

It is O(nlogn) solution.