Longest Consecutive Run of 1s in Binary
Given a non-negative integer n
, return the length of the longest consecutive run of 1
s in its binary representation.
Constraints
0 ≤ n < 2 ** 31
https://binarysearch.com/problems/Longest-Consecutive-Run-of-1s-in-Binary
Examples
Example 1
Input
- n =
156
Output
- answer =
3
Explanation
156 is10011100
in binary and there’s a run of length 3.
Leave a comment