Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
reknahs authored Feb 9, 2023
1 parent 19ccc4b commit 87f6f30
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions codeforces/prependappend/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <iostream>
#include <deque>
using namespace std;

void solve() {
int n;
cin >> n;
deque<int> string(n);
for(int i = 0; i < n; i++) {
char c;
cin >> c;
string[i] = c-48;
}

int count = 0;
while(string.size() > 1 && string.back() != string.front()) {
count++;
string.pop_back();
string.pop_front();
}
cout << n-2*count << endl;
}

int main() {
int t;
cin >> t;
for(int i = 0; i < t; i++) solve();
}

0 comments on commit 87f6f30

Please sign in to comment.