Cover image for LeetCode Daily Problem P3370 Smallest Integer With Only Set Bits

LeetCode Daily Problem P3370 Smallest Integer With Only Set Bits


Timeline

Timeline

2025-10-29

init

Bit manipulation

Problem:

Simple Bit Manipulation

12345678910111213
struct Solution;impl Solution {    pub fn smallest_number(n: i32) -> i32 {        let mut i = 1_i64;        while i < n as i64 {            i = (i << 1) | 1;        }        i as i32    }}fn main() {    println!("Hello, world!");}
Loading comments…