Bitwise OR of Even Numbers in an Array

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.

Example 1
Inputnums = [1,2,3,4,5,6]
Output6
The even numbers are 2, 4, and 6, and their bitwise OR equals 6.
Example 2
Inputnums = [7,9,11]
Output0
There are no even numbers, so the result is 0.

Constraints

  • 1 <= nums.length <= 100
  • 1 <= nums[i] <= 100

Asked at 2 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate