方法一:
class Solution {
public String customSortString(String order, String s) {
int[] count = new int[26];
// 对s中出现大的字符进行计数
for(char c : s.toCharArray()) {
count[c - 'a'] += 1;
}
StringBuilder sb = new StringBuilder();
for(char c : order.toCharArray()) {
while(count[c - 'a'] > 0) {
sb.append(c);
count[c - 'a']--;
}
}
for(int i = 0; i < count.length; i++) {
while(count[i] != 0) {
sb.append((char) (i + 'a'));
count[i]--;
}
}
return sb.toString();
}
}