To get the next elements we have to calculate xor of previous elements with given xor of 2 consecutive elements . e . g . if a ^ b = k1 so to get b xor a both side . b = k1 ^ a
$ elements [ $ i + 1 ] = $ arr [ $ i ] ^ $ elements [ $ i ] ; }