Greedy algorithm

how to figure it out that we should apply counting sort in this question?? but we don’t use it usually and prefer the inbuilt sort function??

@shampblocks,
Yes, it would be quite difficult to come up yourself the first time you try this problem, but after doing it ones, you have a understanding how counting sort can be used. I am sure you will be able to analogously relate to this problem next time you see a problem involving counting sort(which would be rare though)

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.