Counting sort (why testcase is giving wrong answer)
Hello @Saksham12,
Your Code will fail for the case when numbers are repeating:
Example:
3 2 4 1 3 5
Expected Result:
1 2 3 3 4 5
Your Output:
1 2 3 4 5
Solution:
- You have to print i, freq[i] times.
- Initialize your freq[] array with 0.
Modified Code:
Hope, this would help.
Give a like if you are satisfied.
1 Like
Thanks for the modification
I am currently not doing the work I will mark it resolved later