Simple O(nlogn)


#1

int Solution::solve(vector &A) {
sort(A.begin(),A.end());
return A[0]+A[A.size()-1];
}


#2

@saurabh-kumar-pal we have to find minimize comparisons…a trivial way to solve is in 2N comparisons but NlogN is way more than 2N…and answer is even less than 2N it’s around 3*N/2 comparisons