fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. string s;cin>>s;
  7. int i=0;
  8. int j=s.size()-1;
  9. int maxx=0;
  10. while(i<=j){
  11. if(s[i]!=s[j]){
  12. j=s.size();
  13. }else{
  14. maxx=max(maxx,j-i+1);
  15. }
  16. i++,j--;
  17. }
  18. cout<<maxx<<"\n";
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5548KB
stdin
aaaabbaa
stdout
8