Ctrl K

An Even Bitwise OR

Easy
You are given a list of positive integers values. Can you pick two or more of its elements so that their bitwise OR (|) ends with at least one zero in binary? For example, 6 is 110 in binary and ends with a zero, while 5 is 101 and does not. Return True if such a choice exists, and False otherwise.
Example 1
values=[3, 10, 7, 12] → True

10 | 12 = 14, which is 1110 in binary and ends with a zero.

Example 2
values=[5, 8, 11] → False

Only 8 is even. Any group of two or more takes in an odd number, which sets the last bit of the OR.

Example 3
values=[2, 2] → True
Constraints
  • 2 ≤ len(values) ≤ 10⁵
  • 1 ≤ values[i] ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Unpaired Value EasyThe Lost Ticket EasyDoubled Tag, Lost Tag EasyMirror and Negate a Bitmap EasyMultiple of Five at Every Step Easy
loading Python…
Input
values=[3, 10, 7, 12]
Expected
True

Run checks the first 3 tests in your browser. Submit checks all 122 tests on the server, hidden ones included.