3827. Count Monobit Integers Easy
1/**
2 * [3827] Count Monobit Integers
3 *
4 * You are given an integer n.
5 * An integer is called Monobit if all bits in its binary representation are the same.
6 * Return the count of Monobit integers in the range [0, n] (inclusive).
7 *
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">n = 1</span>
11 * Output: <span class="example-io">2</span>
12 * Explanation:
13 *
14 * The integers in the range [0, 1] have binary representations "0" and "1".
15 * Each representation consists of identical bits. Thus, the answer is 2.
16 * </div>
17 * <strong class="example">Example 2:
18 * <div class="example-block">
19 * Input: <span class="example-io">n = 4</span>
20 * Output: <span class="example-io">3</span>
21 * Explanation:
22 *
23 * The integers in the range [0, 4] include binaries "0", "1", "10", "11", and "100".
24 * Only 0, 1 and 3 satisfy the Monobit condition. Thus, the answer is 3.
25 * </div>
26 *
27 * Constraints:
28 *
29 * 0 <= n <= 1000
30 *
31 */
32pub struct Solution {}
33
34// problem: https://leetcode.com/problems/count-monobit-integers/
35// discuss: https://leetcode.com/problems/count-monobit-integers/discuss/?currentPage=1&orderBy=most_votes&query=
36
37// submission codes start here
38
39impl Solution {
40 pub fn count_monobit(n: i32) -> i32 {
41 0
42 }
43}
44
45// submission codes end
46
47#[cfg(test)]
48mod tests {
49 use super::*;
50
51 #[test]
52 fn test_3827() {
53 }
54}
55Back
© 2026 bowen.ge All Rights Reserved.