题目
代码
class Solution {
public:
string customSortString(string S, string T) {
vector<int> table(26, 0);
string ans = "";
for(auto t : T) table[t - 'a']++;
for(auto s : S){
if(table[s - 'a'] > 0){
while(table[s - 'a'] > 0){
ans += s;
table[s - 'a']--;
}
}
}
for(int i = 0; i < 26;i++){
if(table[i] > 0){
while(table[i] > 0){
ans += i + 'a';
table[i]--;
}
}
}
return ans;
}
};