Run time error could u please help in finding the error


could u please help in finding the error

@kartiksaxena2000
It is specified in the constraints that you can get an array as large as 10^6. You have only declared an array of size 10^3. Increase the size of your array.

its still is not working

@kartiksaxena2000
Either declare array b statically of size 10^6 or declare it as
b = new int[m+1] {0} ;

Do not use malloc.

Also , your counting sort implementation is wrong. Do not update a[m] in your loop as that is bound to give you a runtime error. Update your array a from index 0.
int q = 0 ;
.
.
.
// and then in your loop
a[q] = i;
q++;

Do not use variable m for this part.

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.

i am not able to correct my code could you please comment the changes in my code