Cover image for leetcode每日一题 P3370 仅含置位位的最小整数

leetcode每日一题 P3370 仅含置位位的最小整数


时间轴

时间轴

2025-10-29

init

位运算

题目:

简单的位运算

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!");}
评论加载中…