Trailing Zero Bits

EasyBit ManipulationMath

Description

Given a non-negative integer n, return the number of trailing zero bits in its binary representation. For n = 0, return 0.

Examples

Input:n = 8
Output:3
Explanation:

Binary 1000 has 3 trailing zeros.

Input:n = 7
Output:0
Explanation:

Binary 111 ends with a 1.

Input:n = 0
Output:0
Explanation:

By convention the trailing-zero count for n = 0 is defined as 0.

Constraints

  • 0 ≤ n < 2³²

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.