Skip to main content
Back to problems
#3064
Medium Algorithms

Guess the number using bitwise questions i

Bit Manipulation Interactive
89.0% acceptance
Mar 31, 2026
12
11

No description available.

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  unsafe fn find_number() -> i32 {
    let mut result = 0;
    for i in 0..30 {
      if unsafe { common_set_bits(1 << i) } > 0 {
        result |= 1 << i;
      }
    }
    result
  }
}