In general, you cannot achieve a greater time than for sorting algorithms where you need to compare the array elements. However, counting sort sorts an array in time assuming every element in the array is an integer between 0….
Here, we keep a bookkeeping array whose indices are the elements of the original array and the value is the frequency each element showed up in the original array.
Making this array takes time. After this the sorted array can be created in time using the bookkeeping array.
In this method of sorting, we don’t care about the values of the array elements but their frequency which is why we can sort in time.