# Maxi AND CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

Table of Contents

## Maxi AND CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

## Maxi AND CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

## Problem Statement

#### You are given an array ‘A’ consisting of ‘N’ positive integers.

#### You can perform the following operation any number of times:

#### ● Choose any index ‘i’ such that 1 <= ‘i’ <= ‘N’ and select any integer ‘X’ such that ‘1 <= X <= A[i]’, change ‘A[i]’ to ‘A[i] xor X’.

#### Find the maximum possible AND of the whole array ‘A’.

#### Note: AND of the array is ‘A[1] & A[2] & A[3] & … & A[N]’.

##### Example:

```
'N' = 3
'A' = [3, 5, 4]
We do the following operations:
Change 'A[2]' to 'A[2] xor 2 = 7'.
Change 'A[3]' to 'A[3] xor 3 = 7'.
The AND of the new array is '3 & 7 & 7 = 3'.
It can be shown that this is the maximum possible AND.
```

##### Hint:

```
The operation can activate all bits less than an element's MSB (Most Significant Bit). Use the element with the smallest MSB to determine the answer.
```

Detailed explanation ( Input/output format, Notes, Images )

##### Constraints :

```
1 <= T <= 10
1 <= N <= 10^5
1 <= A[i] <= 10^6
Time Limit: 1 sec
```

##### Sample Input 1:

```
2
4
1 3 5 8
2
6 7
```

##### Sample Output 1:

```
1
7
```

##### Explanation Of Sample Input 1:

```
For test case 1:
The AND of the given array is '1 & 3 & 5 & 8 = 1'.
It can be shown that this is already the maximum possible AND.
For test case 2:
We do the following operation:
Change 'A[1]' to 'A[1] xor 1 = 7'.
The AND of the new array is '7 & 7 = 7'.
It can be shown that this is the maximum possible AND.
```

##### Sample Input 2:

```
2
3
10 10 10
5
15 35 25 30 20
```

##### Sample Output 2:

```
15
15
```

6 digit code appear after 69 seconds.

**Wait for Solution**

## We are Still Solving…. Please Visit Our Social Media Handle Till Then

## Here Discuss About Maxi AND CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

## Maxi AND CodeKaze June23 Round 2 Solution || India’s Biggest Hiring Challenge

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer Then **Follow US HERE **and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE