O(logn) simple solution


#1
int Solution::maxp3(vector<int> &arr) {
    int n=arr.size();
        sort(arr.begin(),arr.end());
        int ans=INT_MIN;
        ans=max(ans,( (arr[0]*arr[1])*arr[n-1] ) );
        ans=max(ans, ( (arr[n-3]*arr[n-2])*arr[n-1] ) );
        return ans;
}

#2

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


#3

Bro Are you sure this is not O(n*logn) solution!!!