CT059

Longest Consecutive Ones

EasyAcceptance: 0.0%

Given an integer n, return the length of the longest consecutive run of ones in its binary representation. Input: a single integer. Output: the length of the longest run of 1s.

Example 1:

Input: 156
Output: 3

Example 2:

Input: 15
Output: 4

Constraints:

0 <= n <= 2^31 - 1

Tags:

bit-manipulation
Loading...
Test Cases:No test cases
No test cases available.
Coding Problem Not Found | CodeTikki