Dsa
Bit Manipulation
Medium
Find the Rightmost Set Bit
Given an integer n, find the position of the rightmost set bit (1) in its binary representation. The position is 1-indexed. Print '0' if there are no set bits.
Input:
A single integer n.
Output:
An integer representing the position of the rightmost set bit or '0' if there are none.
Example:
Input:
18
Output:
2
Key concepts
bit_manipulationpositioning
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