human
Can you provide a code to check for Palindrome after every character replacement Query and the other steps required given the following:
Check for Palindrome after every character replacement Query | Function to check if string is Palindrome or Not.
Takes two inputs for Q queries . For every query , it prints Yes if string becomes palindrome and No if not ..
Process all queries one by one.
query 1 : i1 = 3 , i2 = 0 , ch = ' e ' query 2 : i1 = 0 , i2 = 2 , ch = ' s ' replace character at index i1 & i2 with new ' ch '.
check string is palindrome or not.
Driver Code"
Solution in Python:
assistant
#Here is code to check for Palindrome after every character replacement Query and the other steps required.
 def isPalindrome ( string : list ) -> bool :
	n = len ( string )
	for i in range ( n // 2 ) :
		if string [ i ] != string [ n - 1 - i ] :
			return False
	return True
def Query ( string : list , Q : int ) -> None :
	for i in range ( Q ) :
		inp = list ( input ( ) . split ( ) )
		i1 = int ( inp [ 0 ] )
		i2 = int ( inp [ 1 ] )
		ch = inp [ 2 ]
		string [ i1 ] = string [ i2 ] = ch
		if isPalindrome ( string ) :
			print ( " Yes " )
		else :
			print ( " No " )
if __name__ == " _ _ main _ _ " :
	string = list ( " geeks " )
	Q = 2
	Query ( string , Q )