What could be the space and time complexity for this?

programming
Tags: #<Tag:0x00007f1825dc4d28>

#1

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


#2

TC: O(nlogn)
SC: O(1)
If you are doing sorting for this question then this is very bad decision.