Simple o(n) sol in 2 line


#1

long int mx = *max_element(A.begin(),A.end());
long int mn = *min_element(A.begin(), A.end());

return (int)(mx+mn);