Binary array after M range toggle operations | function for toggle ; function for final processing of array ; function for printing result ; Driver Code ; function call for toggle ; process array ; print result
< ? php function command ( $ arr , $ a , $ b ) { $ arr [ $ a ] = $ arr [ $ a ] ^ 1 ; $ arr [ $ b + 1 ] ^= 1 ; } function process ( $ arr , $ n ) { for ( $ k = 1 ; $ k <= $ n ; $ k ++ ) { $ arr [ $ k ] = $ arr [ $ k ] ^ $ arr [ $ k - 1 ] ; } } function result ( $ arr , $ n ) { for ( $ k = 1 ; $ k <= $ n ; $ k ++ ) echo $ arr [ $ k ] . " ▁ " ; } $ n = 5 ; $ m = 3 ; $ arr = new SplFixedArray ( 7 ) ; $ arr [ 6 ] = array ( 0 ) ; command ( $ arr , 1 , 5 ) ; command ( $ arr , 2 , 5 ) ; command ( $ arr , 3 , 5 ) ; process ( $ arr , $ n ) ; result ( $ arr , $ n ) ; ? >