 # Game with nos solution in python

You are given an array arr[], you have to re-construct an array arr[].
The values in arr[] are obtained by doing Xor of consecutive elements in the array.

Example 1:

```â€‹Input : arr[ ] = {10, 11, 1, 2, 3}
Output : 1 10 3 1 3
Explanation:
At index 0, arr xor arr = 1
At index 1, arr xor arr = 10
At index 2, arr xor arr = 3
...
At index 4, No element is left So, it will remain as
it is.
New Array will be {1, 10, 3, 1, 3}.
```

â€‹Example 2:

```Input : arr[ ] = {5, 9, 7, 6}
Output :  12 14 1 6 ```

This is a function problem. The input is already taken care of by the driver code. You only need to complete the function game_with_number() that takes an array (arr), sizeOfArray (n), and return the array re-constructed array arr. The driver code takes care of the printing.

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(1).

Constraints:

1 ≤ N ≤ 105

1 ≤ arr[i] ≤ 107

## Solution

def game_with_number (arr, n) :
#Complete the function
for i in range (n-1):
#arr.reverse()
arr[i]=arr[i]^arr[i+1]
return arr

Python for You

Roles For Data Scientists? #### techengers

• […] Game with nos solution in python […]

• […] Game with nos solution in python […]