Quadruplet pair with XOR zero in the given Array | PHP implementation of the approach ; Function that returns true if the array contains a valid quadruplet pair ; We can always find a valid quadruplet pair for array size greater than MAX ; For smaller size arrays , perform brute force ; Driver code
< ? php const MAX = 130 ; function validQuadruple ( $ arr , $ n ) { if ( $ n >= MAX ) return true ; for ( $ i = 0 ; $ i < $ n ; $ i ++ ) for ( $ j = $ i + 1 ; $ j < $ n ; $ j ++ ) for ( $ k = $ j + 1 ; $ k < $ n ; $ k ++ ) for ( $ l = $ k + 1 ; $ l < $ n ; $ l ++ ) { if ( ( $ arr [ $ i ] ^ $ arr [ $ j ] ^ $ arr [ $ k ] ^ $ arr [ $ l ] ) == 0 ) { return true ; } } return false ; } $ arr = array ( 1 , 0 , 2 , 3 , 7 ) ; $ n = count ( $ arr ) ; if ( validQuadruple ( $ arr , $ n ) ) echo ( " Yes " ) ; else echo ( " No " ) ; ? >