You're given an array of positive integers, and your task is to determine if it's possible to select two or more elements such that their bitwise OR operation results in a number with at least one trailing zero.
A trailing zero in binary representation means the number ends with one or more '0' bits. For example:
5in binary is"101"- no trailing zeros4in binary is"100"- two trailing zeros12in binary is"1100"- two trailing zeros
Return true if such a selection is possible, false otherwise.
Key insight: A number has trailing zeros if and only if it's divisible by 2 (even). So we need to find if any combination of 2+ elements can produce an even OR result.
Input & Output
Visualization
Time & Space Complexity
Single pass through the array to count even numbers
Only storing a counter variable
Constraints
- 2 โค nums.length โค 100
- 1 โค nums[i] โค 100
- All integers are positive