human
Maximum length palindromic substring for every index such that it starts and ends at that index | Function to return true if S [ i ... j ] is a palindrome.
Iterate until i < j.
If unequal character encountered.
Otherwise.
Function to find for every index , longest palindromic substrings starting or ending at that index.
Stores the maximum palindromic substring length for each index.
Traverse the string.
Stores the maximum length of palindromic substring.
Consider that palindromic substring ends at index i.
If current character is a valid starting index.
If S [ i , j ] is palindrome ,.
Update the length of the longest palindrome.
Consider that palindromic substring starts at index i.
If current character is a valid ending index.
If str [ i , j ] is palindrome.
Update the length of the longest palindrome.
Update length of the longest palindromic substring for index i.
Print the length of the longest palindromic substring.
Driver Code"
Solution in Python:
 ... What is a code to maximum length palindromic substring for every index such that it starts and ends at that index and the other steps required?
assistant
#Here is code to maximum length palindromic substring for every index such that it starts and ends at that index and the other steps required.
 def isPalindrome ( S , i , j ) :
	while ( i < j ) :
		if ( S [ i ] != S [ j ] ) :
		return False
		i += 1
		j -= 1
	return True
def printLongestPalindrome ( S , N ) :
	palLength = [ 0 for i in range ( N ) ]
	for i in range ( N ) :
		maxlength = 1
		for j in range ( i ) :
		if ( S [ j ] == S [ i ] ) :
			if ( isPalindrome ( S , j , i ) ) :
			maxlength = i - j + 1
			break
		j = N - 1
		while ( j > i ) :
		if ( S [ j ] == S [ i ] ) :
			if ( isPalindrome ( S , i , j ) ) :
			maxlength = max ( j - i + 1 , maxlength )
			break
		j -= 1
		palLength [ i ] = maxlength
	for i in range ( N ) :
		print ( palLength [ i ] , end = " ▁ " )
if __name__ == ' _ _ main _ _ ' :
	S = " bababa "
	N = len ( S )
	printLongestPalindrome ( S , N )