Skip to main content
Back to problems
#3688
Easy Algorithms

Bitwise or of even numbers in an array

Array Bit Manipulation Simulation
84.8% acceptance
Feb 25, 2026
35
4
You are given an integer array nums. Return the bitwise OR of all even numbers in the array. If there are no even numbers in nums, return 0.

Solution

Rust
Time O(n)
Space O(1)
LeetCode
solution.rs
impl Solution {
  pub fn even_number_bitwise_o_rs(nums: Vec<i32>) -> i32 {
    nums.iter().filter(|&&x| x % 2 == 0).fold(0, |acc, &x| acc | x)
  }
}