Can you check if this is the most efficient approach , i was having doubts whether this was the best way to go about the problem
@pradyumn25jain you could use a simple count sort technique because the range of elements is limited. Make a freq array of size 3 and update the frequencies in O(n) time. Then you can either directly output each element for freq[i] times or you could store it in the array and print that array.
Yeah sure thank you , will try that
1 Like