Dsa
Bit Manipulation
Easy
Count Pairs with Different Bits
You are given a list of integers. Your task is to count the number of pairs of integers in the list that have different bits in the same positions. For example, in the list [1, 2, 3], the count of pairs with different bits is 3.
Input Format:
- First line contains a single integer n (1 <= n <= 1000), the number of integers in the list.
- Second line contains n space-separated integers.
Output Format:
- Output a single integer, the count of pairs with different bits.
Example:
Input:
3
1 2 3
Output:
3
Key concepts
bit_manipulationpair_countingcombinatorics
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