We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
We need to print sorted elkements n no. of times as it appears. So we are first counting the no. of times the NUMBER appears between 1 to 100 and then storing (no. of times it appears) in the respective Array index.
e.g if 3 appears 5 times.
We have A[3]=5;
In that way, we use j index to access sequentially all elements to print them That many times as they appear.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Counting Sort 2
You are viewing a single comment's thread. Return to all comments →
We need to print sorted elkements n no. of times as it appears. So we are first counting the no. of times the NUMBER appears between 1 to 100 and then storing (no. of times it appears) in the respective Array index.
e.g if 3 appears 5 times. We have A[3]=5;
In that way, we use j index to access sequentially all elements to print them That many times as they appear.