We have a number N. Determine the length of longest consecutive 0’s in its binary representation.
Input : N = 14 Output : 1 Binary representation of 14 is 1110. There is only one 0 in the binary representation. Input : N = 9 Output : 2
A simple approach is to traverse through all bits and keep track of maximum number of consecutive 0s.
- Length of the Longest Consecutive 1s in Binary Representation
- Find consecutive 1s of length >= n in binary representation of a number
- 1 to n bit numbers with no consecutive 1s in binary representation.
- 1 to n bit numbers with no consecutive 1s in binary representation
- Find longest sequence of 1's in binary representation with one flip
- Binary representation of a given number
- Count number of trailing zeros in Binary representation of a number using Bitset
- Check if the binary representation of a number has equal number of 0s and 1s in blocks
- Binary representation of previous number
- Largest number with binary representation is m 1's and m-1 0's
- Next greater number than N with exactly one bit different in binary representation of N
- Number of leading zeros in binary representation of a given number
- Occurrences of a pattern in binary representation of a number
- Prime Number of Set Bits in Binary Representation | Set 1
- Check if binary representation of a number is palindrome
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.