Longest AND Subarray | ANDSUBAR | Codechef Solution | Codechef October Challenge 2021 | TechTalkBot
Code:- ANDSUBAR
Name:- MEX-OR
Codechef October 2021 long challenge
By TECHTALKBOT
The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:
- The MEX of is , because does not belong to the array.
- The MEX of is , because and belong to the array, but does not.
- The MEX of is 4 because and belong to the array, but does not.
Find the maximum possible MEX of an array of non-negative integers such that the bitwise OR of the elements in the array does not exceed .
The MEX (minimum excluded) of an array is the smallest non-negative integer that does not belong to the array. For instance:
- The MEX of is , because does not belong to the array.
- The MEX of is , because and belong to the array, but does not.
- The MEX of is 4 because and belong to the array, but does not.
Find the maximum possible MEX of an array of non-negative integers such that the bitwise OR of the elements in the array does not exceed .
Input Format
- The first line contains denoting the number of test cases. Then the test cases follow.
- Each test case contains a single integer on a single line.
- The first line contains denoting the number of test cases. Then the test cases follow.
- Each test case contains a single integer on a single line.
Output Format
For each test case, output on a single line the maximum possible MEX of the array satisfying the given property.
For each test case, output on a single line the maximum possible MEX of the array satisfying the given property.
Constraints
Subtasks
Subtask 1 (100 points): Original constraints
Subtask 1 (100 points): Original constraints
Sample Input 1
4
0
1
2
5
4
0
1
2
5
Sample Output 1
1
2
2
4
1
2
2
4
Explanation
Test case : The array could be .
Test case : The array could be . Here the bitwise OR of and is and the MEX of the array is as both and belongs to the array.
Test case : The array could be . Here the bitwise OR of all integers in the array is and the MEX of the array is .
Test case : The array could be .
Test case : The array could be . Here the bitwise OR of and is and the MEX of the array is as both and belongs to the array.
Test case : The array could be . Here the bitwise OR of all integers in the array is and the MEX of the array is .
Solution:
- COMING SOON.... STAY TUNED
- COMING SOON.... STAY TUNED
Conclusion:
- Keep ReadingThank You
If you are interested in Google Analytics Academy CertificationCheck out this-
- Keep ReadingThank YouIf you are interested in Google Analytics Academy CertificationCheck out this-
Tags:
Solutions