For instance, ABBA is a palindrome, but ABCBB is not. You are given a string s. Return the length of the longest substring of s that is a palindrome..program in c++

I strongly suggest that you have a go at doing your own homework as per the community rules:
https://www.daniweb.com/community/rules

If you have trouble finding it, under the "Keep It Organized" section is this rule:
Do provide evidence of having done some work yourself if posting questions from school or work assignments.

Your post above displays no evidence that you have tried to do any of your homework. The community here will not do your homework for you, or spoon-feed you code. We will only help you when you get stuck with something specific.

Start writing your program. If you hit upon any problems that you cannot solve, post the code that you have so far and describe the problems/errors you are experiencing and someone here will help you!

Remember: The amount of effort that you put into your posts will determine the amount of effort that others will put in to help you!

Comments
Well Said.

consider iterating through the string for the various substrings, working from biggest substring to smallest, doing it in this order you find the biggest one first and then you have found it. With each substring, reverse it and compare. if the string is 8 characters long, flip it check it, if it fails, reduce it to 7, get the substring at (0,7) flip it, check it, if it fails try the substring at (1,7) if it fails then try 6, which will require checks of (0,6),(1,6),(2,6) etc on down.

This article has been dead for over six months. Start a new discussion instead.