Binary Numbers – HackerRank Problem solution

Question:

Given a base- 10 integer, n, convert it to binary (base-2). Then find and print the base-10 integer denoting the maximum number of consecutive 1’s in n

Input:

5

Output:

1

Explanation

Sample Case 1:
The binary representation of 5 is 101, so the maximum number of consecutive 1’s is 1.

Here is original problem from HackerRank

Answer:

Leave a Reply

Your email address will not be published. Required fields are marked *