Simple O(N) c++solution


#1

int Solution::solve(vector &A) {
int min=A[0],max=A[0];
for (int i=0;i<A.size();i++)
{
if(A[i]<min)
{
min=A[i];
}
if(A[i]>max)
{
max=A[i];
}
}
return min+max;
}