Skip to content

Commit a542c04

Browse files
committed
Added 1791C - Prepend and Append.cpp
1 parent 94e3284 commit a542c04

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

1791C - Prepend and Append.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
#define ll long long
5+
6+
// Code Written By: Vikash Patel
7+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8+
9+
int main()
10+
{
11+
int t;
12+
cin>>t;
13+
while(t--)
14+
{
15+
int n;
16+
cin>>n;
17+
string s;
18+
cin>>s;
19+
int c = 0;
20+
int j = n-1;
21+
for(int i=0; i<n/2; i++)
22+
{
23+
if(s[i]==s[j-i])
24+
break;
25+
if(s[i]!=s[j-i])
26+
c += 2;
27+
}
28+
cout<<n-c<<endl;
29+
}
30+
return 0;
31+
}

0 commit comments

Comments
 (0)