LeetCode solutions

4009. Bitwise OR of Even Numbers in an Array

My accepted Python solution to LeetCode problem 4009, Bitwise OR of Even Numbers in an Array, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-30.

python
class Solution:
    def evenNumberBitwiseORs(self, nums: List[int]) -> int:
        result = 0
        for num in nums:
            if num % 2 == 0:
                result |= num
        return result

Source