If in our auxiliary array we write the frequency of each of the elements to their respective indices on our frequency array. How can we deal with the negative numbers?
Counting Sort - Can we apply counting sort on negative number?
@raghav6 One way you can handle such cases is by doing a manual mapping.
Say you have array elements as : -9, 1, 2, 7, 3, 6, -1
Most negative element is -9.
So take index for -9 as 0(ie. -9+ 9)
Take index for 1 as 1+9=10
index for 2 as 2+9=11 and so on.
So by doing such index manipulation you can handle the negative numbers.
Hope this helps