Create an array such that XOR of subarrays of length K is X | Function to construct the array ; Creating a list of size K , initialised with 0 ; Initialising the first element with the given XOR ; Driver code
def constructArray ( N , K , X ) : NEW_LINE INDENT ans = [ ] NEW_LINE for i in range ( 0 , K ) : NEW_LINE INDENT ans . append ( 0 ) NEW_LINE DEDENT ans [ 0 ] = X NEW_LINE for i in range ( 0 , N ) : NEW_LINE INDENT print ( ans [ i % K ] , end = " ▁ " ) NEW_LINE DEDENT DEDENT N = 5 NEW_LINE K = 2 NEW_LINE X = 4 NEW_LINE constructArray ( N , K , X ) NEW_LINE