Source Code
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,m="";
    cin>>s;
    int cnt=2,j=1;
    m.push_back(s[0]);
    m.push_back(s[s.size()-1]);
    for(int i=s.size()-2;i>1;i--){
        string l="";
        l.push_back(s[j]);
        l.push_back(s[i]);
        j++;
        if(l==m){
            cnt++;
            l.pop_back();
            l.pop_back();
        }
        else break;
    }
    if(cnt==2)cout<<0<<endl;
    else cout<<cnt<<endl;
}
Copy
Pop Pop sharlok not active_74
GNU G++17
1 ms
184 KB
Wrong Answer