isEvenOddBitwise
Determine if a number is even or odd using bitwise operators. Do not use the modulo operator (%).
Examples
isEvenOddBitwise(4) → 'Even'
isEvenOddBitwise(7) → 'Odd'
Starter code
function isEvenOddBitwise(n) {
}
Complexity of the optimal solution
Time O(1), space O(1). The bitwise AND operation with 1 checks the least significant bit. If it's 0, the number is even; if it's 1, the number is odd. This is a single, constant time operation.