Dsa
Bit Manipulation
Hard
Bitwise OR and Count
Given a list of integers, compute the bitwise OR of all the elements and also count how many bits are set to 1 in the resulting number. Your function should read the integers from input, and output both the bitwise OR result and the count of bits set to 1.
Example:
Input:
1 2 3 4
Output:
7 3
// Explanation: The bitwise OR of 1, 2, 3, and 4 is 7. The count of bits set to 1 in 7 (0111) is 3.
Key concepts
bit_manipulationbitwise_operationscounting
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