Please tell what is the problem in my code
Getting segmentation fault in Counting sort problem
I guess you shared wrong code, this code is for some other problem and not of counting sort.
Sorry, please check this code:
Please be patient, I’ll debug it and let you know 
Hey @sahilkhan2312000131
The issue is with your countsort function in these conditions
for(int i=0;i<size;i++)
count[i]+=count[i-1];
for(int i = n - 1; i >= 0; i--){
output[count[a[i]-min]-1]=a[i];
count[a[i]-min]--;
}
Take reference from this code and apply it in your code, and if need any help. Can ask for it.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.