How to make this faster? This is giving TLE for QUALPREL

enter code here
#include<stdio.h>
#include<stdlib.h>

int partition(int *arr, int start, int end){  
  int i=start+1, j=end, temp;  
  while(i<j){  
    while(arr*>=arr[start]){
      i++;
    }
    while(arr[j]<arr[start]){
      j--;
    }
    if(i<j){
      temp=arr*;
      arr*=arr[j];
      arr[j]=temp;
      j--;
    }
}
temp=arr[start];
arr[start]=arr[j];
arr[j]=temp;
return j;
}
void quicksort(int *arr, int start, int end){
  if(start<end){
    int index=partition(arr, start, end);
    quicksort(arr, start, index-1);
    quicksort(arr, index+1, end);
  }
}
int main(){
int i, t, n, k, count, *ptr;
scanf("%d", &t);
while(t--){
  scanf("%d %d", &n, &k);
  ptr=(int*)malloc(n*sizeof(int));
  for(i=0;i<n;i++){
    scanf("%d", &ptr*);
  }
  count=0;
  quicksort(ptr, 0, n-1);
  i=0;
  while(ptr*>=ptr[k-1]){
    count++;
    i++;
  }
  printf("%d

", count);
}

return 0;
}

Your approach is correct. But your sorting algorithm is taking a long time. Either you can use built-in c’s qsort, or you can learn some faster-sorting algorithms such as Merge Sort.