human
Minimum insertions to form shortest palindrome | Returns true if a string str [ st . . end ] is palindrome.
Returns count of insertions on left side to make str [ ] a palindrome.
Find the largest prefix of given string that is palindrome ..
Characters after the palindromic prefix must be added at the beginning also to make the complete string palindrome.
Driver Code"
Solution in Python:
assistant
#Here is code to minimum insertions to form shortest palindrome and the other steps required.
 def isPalin ( str , st , end ) :
	while ( st < end ) :
		if ( str [ st ] != str [ end ] ) :
			return False
		st += 1
		end - - 1
	return True
def findMinInsert ( str , n ) :
	for i in range ( n - 1 , - 1 , - 1 ) :
		if ( isPalin ( str , 0 , i ) ) :
			return ( n - i - 1 )
Input = " JAVA "
print ( findMinInsert ( Input , len ( Input ) ) )