1301. Count Trailing Zeros Using Bit Trick

EasyBit ManipulationBit ManipulationTrailing ZerosLowest Set Bit

Given a non-negative integer n, return the number of consecutive 0-bits at the least-significant end of its binary representation. By convention, if n is 0 return 0.

Input: A JSON object {"n": <non-negative integer>}.

Output: Return the count of trailing zero bits.

Examples

Example 1
Input: {"n":12}
Output: 2
Explanation: 12 is 1100; two trailing zeros -> 2.
Example 2
Input: {"n":8}
Output: 3
Explanation: 8 is 1000; three trailing zeros -> 3.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →