Counting Sort Implementation!

Hi,
Before this section, there was no video on counting sort, so I implemented it using what I read on the internet. But it’s not passing the test case. Please help!
Solution link: https://ide.codingblocks.com/s/369303

@yashjain0112, there are some parts in your code that is not necessary like taking prefix sum and decrementing the index. i have corrected your code, and do tell me any part you find trouble understanding

also take the size of output array as 10^6+1 as it will give you runtime error if array value is 10^6

code link :

In case of any doubt feel free to ask :slight_smile:
Mark your doubt as RESOLVED if no further issue.

1 Like

Okay thank you!
I read some resources and that’s why took a prefix sum array.