Untitled
user_5668965
c_cpp
a year ago
428 B
16
Indexable
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200007;
const int MOD = 1000000007;
void solve() {
int n;
cin >> n;
string s;
cin >> s;
int l = 0, r = n - 1, ans = n;
while (s[l] != s[r] && ans > 0) {l++; r--; ans -= 2;}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve();}
// solve();
}Editor is loading...
Leave a Comment