
integration of bullmq
solution.cpp
#include <bits/stdc++.h>
#ifdef LOCAL
#include "brxteforceman/debug.h"
#else
#define debug(...)
#endif
void solve(int t) {
int n;
std::cin >> n;
std::string s;
std::cin >> s;
std::vector<int> cnt(26, 0);
for (int i = 0; i < n; ++i)
cnt[s[i] - 'a']++;
std::string ans = "";
int j = 0;
for (int i = 0; i < n; ++i) {
while (cnt[j] == 0) {
j++;
j %= 26;
}
ans.push_back(j + 'a');
cnt[j++]--;
j %= 26;
}
std::cout << ans << "\n";
}
signed main(void) {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
auto precompute = [&]() {};
precompute();
int t = 1;
std::cin >> t;
for (int i = 1; i <= t; ++i) {
std::string _t = "testcase (" + std::to_string(i) + ")\n";
debug(_t);
solve(i);
}
}