Quadruplet pair with XOR zero in the given Array | Javascript 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
const MAX = 130 ; function validQuadruple ( arr , n ) { if ( n >= MAX ) return true ; for ( let i = 0 ; i < n ; i ++ ) for ( let j = i + 1 ; j < n ; j ++ ) for ( let k = j + 1 ; k < n ; k ++ ) for ( let l = k + 1 ; l < n ; l ++ ) { if ( ( arr [ i ] ^ arr [ j ] ^ arr [ k ] ^ arr [ l ] ) == 0 ) { return true ; } } return false ; } let arr = [ 1 , 0 , 2 , 3 , 7 ] ; let n = arr . length ; if ( validQuadruple ( arr , n ) ) document . write ( " " ) ; else document . write ( " " ) ;