Maximum XOR value in matrix | PHP program to Find maximum XOR value in matrix either row or column wise maximum number of row and column ; function return the maximum xor value that is either row or column wise ; for row xor and column xor ; traverse matrix ; xor row element ; for each column : j is act as row & i act as column xor column element ; update maximum between r_xor , c_xor ; return maximum xor value ; Driver Code
< ? php $ MAX = 1000 ; function maxXOR ( $ mat , $ N ) { $ r_xor ; $ c_xor ; $ max_xor = 0 ; for ( $ i = 0 ; $ i < $ N ; $ i ++ ) { $ r_xor = 0 ; $ c_xor = 0 ; for ( $ j = 0 ; $ j < $ N ; $ j ++ ) { $ r_xor = $ r_xor ^ $ mat [ $ i ] [ $ j ] ; $ c_xor = $ c_xor ^ $ mat [ $ j ] [ $ i ] ; } if ( $ max_xor < max ( $ r_xor , $ c_xor ) ) $ max_xor = max ( $ r_xor , $ c_xor ) ; } return $ max_xor ; } $ N = 3 ; $ mat = array ( array ( 1 , 5 , 4 ) , array ( 3 , 7 , 2 ) , array ( 5 , 9 , 10 ) ) ; echo " maximum ▁ XOR ▁ value ▁ : ▁ " , maxXOR ( $ mat , $ N ) ; ? >