#3827

Count Monobit Integers

easy · 66.1% accepted · 50 likes · top 71%

bit manipulation · enumeration

Description

You are given an integer n.

An integer is called Monobit if all bits in its binary representation are the same.

Return the count of Monobit integers in the range [0, n] (inclusive).

Solution