Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- string s;
- cin>>s;
- int ans = 1;
- int n = s.size();
- auto isPal = [&](int l, int r)
- {
- for(int i=l, j=r; i<j; i++, j--)
- {
- if(s[i] != s[j])
- return false;
- }
- return true;
- };
- for(int i=0; i<n; i++)
- {
- for(int j=i+1; j<n; j++)
- {
- if(isPal(i, j))
- ans = max(ans, j-i+1);
- }
- }
- cout<<ans<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment