Dsa
Bit Manipulation
Medium
Binary Gap
Find the maximum length of a contiguous sequence of 1s in the binary representation of a given positive integer n.
For example:
Input:
29
Output:
2
Explanation:
The binary representation of 29 is 11101. The maximum gap of 1s is 2.
Key concepts
bit manipulationbinary representation
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