What is wrong with my code?


please help me fix the code

Hi Vivek. I don’t understand what u are exactly trying to do. This is a very simple problem.
refer this https://ide.codingblocks.com/s/582151

i googled count sort and they told me the approach for the same, there is no video in this course for the same

did u go through the solution i gave u… its very easy to undertsand… basically first u find the max element(maxNum) in the array. then u create another array of size maxNum + 1 and initaize it to 0. then u iterate over original array and increase the frequency of elements

Yes sir, i have used the same approach, it is providing correct ans as well but is not accepted in the testcase, can u please tell the error in mine as well

ok let me see it once

So ur code was ok… there was just a minor mistake.
check the constraints 1<=N<=10^6 0<=Ai<=10^6… but u had declared array of smaller size.I have corrected ur code. its working fine now.

Thank you for ur help sir!!

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.

sir, is ur code correct for count sort

yes… its also fine… u still have any doubt??
https://ide.codingblocks.com/s/582159 this is passing the test cases and getting submitted successfully

https://ide.codingblocks.com/s/582151 sir with this code, it shows run time error when submitted on coding blocks

done sir, must have been some glitch, thanks

ok great… hope ur doubt is cleared now

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.