Two line cpp code


#1

int Solution::maxp3(vector &A) {
sort(A.begin(),A.end());
return max(A[0]*A[1]*A[A.size()-1],A[A.size()-1]*A[A.size()-2]*A[A.size()-3]);

}


#2

That’s one of the most shortest approach I have seen for this ques XD.


#3

doesn’t work for -1 -2 -3 -4 -5


#5

Its working correctly