Please verify if my code time compleity is NlogN or not

int Solution::solve(vector &A, int B) {
sort(A.begin(),A.end());
int start =A[0];
int end =A[A.size()-1];

while(start<=end){
    int mid= start + (end-start)/2;
    int sum =0;
    for(int i =A.size()-1;i>=0;i--){
        if(A[i] > mid )sum = sum + A[i]-mid;
        else break;
    }
    if(sum==B)return mid;
    if(sum>B)start= mid+1;
    if(sum<B)end=mid-1;
    
}
return min(start,end);

}

the answer is correct , just use long int sum instead of just int sum ;

Click here to start solving coding interview questions