Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS
What is the number of 1-bits in the bitwise OR of 6, 10 and 12?
- A. 4
- B. 2
- C. 6
- 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.
Practise more Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questionsArrays, Strings, Linked Lists, Stacks, Queues and Hashing: notes and key points
More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions
- For the array [1, -1, 2], how many distinct values appear among its prefix sums, counting the empty prefix 0?
- Four items of weight 4 each must be shipped in 2 boxes of equal capacity C (each box must hold whole items). What is the smallest feasible…
- What is the minimum absolute difference between two distinct elements of [12, 5, 9, 1, 15, 7]?
- How many distinct characters occur at least twice in "programming"?
- With 1-based indexing, what is the sum of i times a[i] for a = [2, 0, 3, 1]?
- For [1, 0, 1, 1, 0, 1, 0, 1], consider windows of length 4. In each window you may flip at most one 0 to 1. What is the largest number of…