Check if Bitwise OR Has Trailing Zeros

You are given an array of positive integers nums.

You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation.

For example, the binary representation of 5, which is "101", does not have any trailing zeros, whereas the binary representation of 4, which is "100", has two trailing zeros.

Return true if it is possible to select two or more elements whose bitwise OR has trailing zeros, return false otherwise.

Example 1
Inputnums = [1,2,3,4,5]
Outputtrue
If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation "110" with one trailing zero.
Example 2
Inputnums = [2,4,8,16]
Outputtrue
If we select the elements 2 and 4, their bitwise OR is 6, which has the binary representation "110" with one trailing zero.

Constraints

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

Asked at 1 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