Queries on substring palindrome formation | Query type 1 : update string position i with character x . ; Print " Yes " if range [ L . . R ] can form palindrome , else print " No " . ; Find the frequency of each character in S [ L ... R ] . ; Checking if more than one character have frequency greater than 1. ; Driver code
< ? php function qType1 ( $ l , $ x , & $ str ) { $ str [ $ l - 1 ] = $ x ; } function qType2 ( $ l , $ r , $ str ) { $ freq = array_fill ( 0 , 27 , 0 ) ; for ( $ i = $ l - 1 ; $ i <= $ r - 1 ; $ i ++ ) $ freq [ ord ( $ str [ $ i ] ) - ord ( ' a ' ) ] ++ ; $ count = 0 ; for ( $ j = 0 ; $ j < 26 ; $ j ++ ) if ( $ freq [ $ j ] % 2 ) $ count ++ ; ( $ count <= 1 ) ? ( print ( " Yes STRNEWLINE " ) ) : ( print ( " No STRNEWLINE " ) ) ; } $ str = " geeksforgeeks " ; $ n = strlen ( $ str ) ; qType1 ( 4 , ' g ' , $ str ) ; qType2 ( 1 , 4 , $ str ) ; qType2 ( 2 , 3 , $ str ) ; qType1 ( 10 , ' t ' , $ str ) ; qType2 ( 10 , 11 , $ str ) ; ? >