Dsa
Bit Manipulation
Hard
Subarray Bit Counting
Given an array of integers, find the maximum number of contiguous subarrays where the bitwise AND of the subarray elements equals a specific target 'k'. Each element in the array is non-negative.
Input format: The first line contains an integer 'n' (1 <= n <= 1000). The second line contains 'n' space-separated integers. The third line contains 'k' (0 <= k <= 1000).
Output format: A single integer representing the count of subarrays matching the AND criteria.
Example: For input '4
5 7 6 4
4', the valid subarrays are [4], so the output is '1'.
Key concepts
bit manipulationsubarrays
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