int Solution::solve(vector &A) {

sort(A.begin(),A.end());

int sum=0;

sum=A[0]+A[A.size()-1];

return sum;

}

# What could be the space and time complexity for this?

TC: O(nlogn)

SC: O(1)

If you are doing sorting for this question then this is very bad decision.