Dsa
Bit Manipulation
Easy
Nibble Mirror Logic
A 'nibble' is a group of 4 bits. A 32-bit unsigned integer contains 8 nibbles. Your task is to 'mirror' every nibble individually. Mirroring a nibble means reversing its 4 bits (e.g., 1011 becomes 1101, or 0x1 becomes 0x8). Output the resulting 32-bit integer in decimal form.
Example:
Input:
10
Output:
5
Explanation:
10 is 1010 in binary. Reversing these 4 bits gives 0101, which is 5.
Key concepts
bit_maskingbit_shiftingnibbles
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