Longest AND Subarray | ANDSUBAR | Codechef Solution | Codechef October Challenge 2021 | TechTalkBot
Code:- ANDSUBAR
Name:- Longest AND Subarray
Codechef October 2021 long challenge
By TECHTALKBOT
You are given an integer . Consider the sequence containing the integers in increasing order (each exactly once). Find the length of the longest subarray in this sequence such that the bitwise AND of all elements in the subarray is positive.
You are given an integer . Consider the sequence containing the integers in increasing order (each exactly once). Find the length of the longest subarray in this sequence such that the bitwise AND of all elements in the subarray is positive.
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 length of the longest subarray that satisfy the given property.
For each test case, output on a single line the length of the longest subarray that satisfy the given property.
Constraints
Subtasks
- Subtask 1 (100 points): Original constraints
- Subtask 1 (100 points): Original constraints
Sample Input 1
5
1
2
3
4
7
5
1
2
3
4
7
Sample Output 1
1
1
2
2
4
1
1
2
2
4
Explanation
Test case : The only possible subarray we can choose is .
Test case : We can't take the entire sequence as a subarray because the bitwise AND of and is zero. We can take either or as a subarray.
Test case : It is optimal to take the subarray and the bitwise AND of and is .
Test case : It is optimal to take the subarray and the bitwise AND of all integers in this subarray is .
Test case : The only possible subarray we can choose is .
Test case : We can't take the entire sequence as a subarray because the bitwise AND of and is zero. We can take either or as a subarray.
Test case : It is optimal to take the subarray and the bitwise AND of and is .
Test case : It is optimal to take the subarray and the bitwise AND of all integers in this subarray 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