Question bank › Bit Manipulation
Dsa Bit Manipulation Easy

The Unique Shadow

In a signal processing system, a bit position k is considered 'Uniquely Shadowed' if, across a set of N input integers, exactly one integer has the k-th bit set to 1. Given N integers, calculate the bitwise OR sum of all bits that are uniquely shadowed. Input Format: The first line contains an integer N. The second line contains N space-separated integers. Output Format: A single integer representing the bitwise OR of all uniquely shadowed bits. Example: Input: 3 5 3 8 Output: 14 Explanation: 5 in binary: 0101 3 in binary: 0011 8 in binary: 1000 - Bit 0 (val 1): Set in 5 and 3 (count=2). Not unique. - Bit 1 (val 2): Set only in 3 (count=1). Unique. - Bit 2 (val 4): Set only in 5 (count=1). Unique. - Bit 3 (val 8): Set only in 8 (count=1). Unique. OR sum of unique bits: 2 | 4 | 8 = 14.

Key concepts

bit_manipulationfrequency_counting

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.