Looks simple but Time limit exceeded, any help?

programming
Tags: #<Tag:0x00007f24284485b0>

#1

int Solution::kthsmallest(const vector &A, int B) {
int i,j=0,n=A.size(),k=B,mid;
int low,high;
low=*min_element(A.begin(),A.end());
while(j<k){
for(i=0;i<n;i++){ //2 1 4 3 2
if(low==A[i]){
j++;
if(j>=k)
return low;
}
}
low++;
}

}