WHAT IS WRONG WITH MY CODE
MY CODE IS https://ide.codingblocks.com/s/37702
QUESTION IS https://hack.codingblocks.com/contests/c/512/437
Counting sort ---------
There are many mistakes in your code. First of all the constraints mentioned in the question are clearly
1<=N<=10^6
0<=Ai<=10^6
But you have taken array of size only 1000.
This would give you runtime error.
Secondly, your code gives wrong input even for sample input
5
1 3 2 6 5
Given output
1 2 3 6 5
But the correct output is
1 2 3 5 6
The logic applied by you is perfectly fine upto line 16 in your code. You are making mistake after that in the for loop, you are applying wrong logic there.
Think about it again, you will get it.