Queries on substring palindrome formation | Query type 1 : update str1ing position i with character x . ; Pr " Yes " if range [ L . . R ] can form palindrome , else pr " No " . ; Find the frequency of each character in S [ L ... R ] . ; Checking if more than one character have frequency greater than 1. ; Driver Code
def qType1 ( l , x , str1 ) : NEW_LINE INDENT str1 [ l - 1 ] = x NEW_LINE DEDENT def qType2 ( l , r , str1 ) : NEW_LINE INDENT freq = [ 0 for i in range ( 27 ) ] NEW_LINE for i in range ( l - 1 , r ) : NEW_LINE INDENT freq [ ord ( str1 [ i ] ) - ord ( ' a ' ) ] += 1 NEW_LINE DEDENT count = 0 NEW_LINE for j in range ( 26 ) : NEW_LINE INDENT if ( freq [ j ] % 2 ) : NEW_LINE INDENT count += 1 NEW_LINE DEDENT DEDENT if count <= 1 : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT str1 = " geeksforgeeks " NEW_LINE str2 = [ i for i in str1 ] NEW_LINE n = len ( str2 ) NEW_LINE qType1 ( 4 , ' g ' , str2 ) NEW_LINE qType2 ( 1 , 4 , str2 ) NEW_LINE qType2 ( 2 , 3 , str2 ) NEW_LINE qType1 ( 10 , ' t ' , str2 ) NEW_LINE qType2 ( 10 , 11 , str2 ) NEW_LINE