P18065 [GeeksforGeeks] Rearrange a string4100
普及-
题目描述

Given a string containing uppercase alphabets and integer digits (from 0 to 9), the task is to print the alphabets in the lexicographical order followed by the sum of digits.
Example 1:
Input: S = "AC2BEW3"
Output: "ABCEW5"
Explanation: 2 + 3 = 5 and we print all
alphabets in the lexicographical order.
Example 2:
Input: S = "ACCBA10D2EW30"
Output: "AABCCDEW6"
Explanation: 0+1+2+3 = 6 and we print all
alphabets in the lexicographical order.
Your Task:
You don't need to read input or print anything. Your task is to complete the function arrangeString() which takes the string S as inputs and returns the modified string.
Expected Time Complexity: O(|S|)
Expected Auxiliary Space: O(26)
Constraints:
1 ≤ |S| ≤ 10^{5}
S contains only upper case alphabets and digits.

输入格式

见题面

输出格式

见题面

样例输入
S = "AC2BEW3"
样例输出
"ABCEW5"