-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounting Sort Question
More file actions
31 lines (23 loc) · 870 Bytes
/
Copy pathCounting Sort Question
File metadata and controls
31 lines (23 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Given a string S consisting of lowercase latin letters, arrange all its letters in lexographical order using Counting Sort.
Input:
The first line of the input contains T denoting number of testcases.Then T test cases follow. Each testcase contains positive integer N denoting the length of string.The last line of input contains the string S.
Output:
For each testcase, in a new line, output the sorted string.
Your Task:
This is a function problem. You only need to complete the function countSort() that takes char array as parameter and return the sorted char array. The printing is done by driver code.
Constraints:
1 <= T <= 105
1 <= N <= 105
Example:
Input:
2
5
edsab
13
geeksforgeeks
Output:
abdes
eeeefggkkorss
Explanation:
Testcase 1: In lexicographical order , string will be abdes.
Testcase 2: In lexicographical order , string will be eeeefggkkorss.