Dsa
Bit Manipulation
Easy
The Persistent Bit
You are given a sequence of N integers representing sensor readings. A 'Reliability Zone' is defined as a contiguous subarray of readings where there is at least one specific bit position (0-31) that is set to 1 in every single element of that subarray. Your task is to find the length of the longest 'Reliability Zone'.
Input Format:
The first line contains an integer N. The second line contains N space-separated integers.
Output Format:
A single integer representing the maximum length.
Example:
Input:
5
7 3 2 6 4
Output:
4
Explanation:
- 7 (111), 3 (011), 2 (010), 6 (110). All have bit index 1 (value 2) set. Length is 4.
- No contiguous subarray of length 5 shares a bit (7, 3, 2, 6, 4 share no bits).
Key concepts
bit_manipulationsliding_window
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now