Why there is run-time error for my below code


#1
bool compare(int a, int b){
return (a>=b);

}

int Solution::maxp3(vector &arr) {
int i, n=arr.size()-1;
sort(arr.begin(), arr.end(), compare);
return max(arr[0]*arr[1]*arr[2], arr[0]*arr[n]*arr[n-1]);
}