Dsa
Bit Manipulation
Hard
Unique Pairing
Given an array of integers, your task is to determine how many unique pairs (i, j) can be formed such that using the bitwise OR operation on the pair results in a number greater than the maximum element in the array. The elements in pairs must be distinct indices.
Input format: First line contains an integer 'n' (1 <= n <= 1000). Second line contains 'n' space-separated integers.
Output format: A single integer representing the count of such unique pairs.
Example: For input '4
1 2 3 4', the maximum is 4, and pairs (2, 3), (1, 3), (1, 4) yield an OR greater than 4, so the output is '3'.
Key concepts
bit manipulationpairing
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