给定2*n个字符串,表示被打乱顺序的字符串数组t,和最终的字符串s,求初始的字符串s。
思路:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define lson p << 1
#define rson p << 1 | 1
const int maxn = 1e6 + 5, inf = 1e9 + 5, maxm = 4e4 + 5, mod = 1e9 + 7, N = 1e6;
int a[maxn], pre[maxn], b[maxn], suf[maxn];
int n, m;
string s;
// string t[maxn];
int qpow(int a, int b){
int res = 1;
while(b){
if(b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
void solve(){
int res = 0;
int k;
cin >> n;
int cnt[26] = {0};
for(int i = 1; i <= 2 * n + 1; i++){
cin >> s;
for(auto c : s){
cnt[c - 'a']++;
}
}
for(int i = 0; i < 26; i++){
if(cnt[i] % 2 == 1){
cout << char('a' + i) << '\n';
return ;
}
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
// fac[0] = 1;
// for(int i = 1; i <= N; i++){
// fac[i] = fac[i - 1] * i % mod;
// }
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}