Dsa
Bit Manipulation
Easy
Orthogonal Transmission
A series of radio frequencies are transmitted as integers. Two adjacent frequencies are 'orthogonal' if they share no common set bits (i.e., their bitwise AND is zero). Given a sequence of N frequencies, find the length of the longest contiguous sub-sequence where every pair of adjacent frequencies is orthogonal.
Example:
Input:
5
5 2 8 4 10
Output:
4
Explanation:
Pairs: (5,2) AND=0, (2,8) AND=0, (8,4) AND=0, (4,10) AND=0. All 4 pairs are orthogonal, but (4,10) is 0100 & 1010 = 0. Wait, 4 (0100) and 10 (1010) share no bits. The whole sequence of 5 might be orthogonal? Let's check: 5&2=0, 2&8=0, 8&4=0, 4&10=0. Length is 5. If the last was 12 (1100), 4&12=4, sequence would break.
Key concepts
bitwise_andsubarraysoptimization
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