Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

What is the number of 1-bits in the bitwise OR of 6, 10 and 12?

  1. A. 4
  2. B. 2
  3. C. 6
  4. D. 3

Correct answer: D. 3

6 is 0110, 10 is 1010 and 12 is 1100; their OR is 1110, which has three 1-bits. The total popcount of the three numbers (the last option) double-counts shared bits.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic