P17976 [GeeksforGeeks] Counting sort
普及-
题目描述

Given a string arr consisting of lowercase english letters, arrange all its letters in lexicographical order using Counting Sort.
Example 1:
Input:
N = 5
S = "edsab"
Output:
abdes
Explanation:
In lexicographical order, string will be
abdes.
Example 2:
Input:
N = 13
S = "geeksforgeeks"
Output:
eeeefggkkorss
Explanation:
In lexicographical order, string will be
eeeefggkkorss.
Your Task:
This is a function problem. You only need to complete the function countSort() that takes string arr as a parameter and returns the sorted string. The printing is done by the driver code.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
1 ≤ N ≤ 10^{5}
Video:

输入格式

见题面

输出格式

见题面

样例输入
N = 5 S = "edsab"
样例输出
abdes