Check if a Number is Odd or Even

Implement isOdd

Given an integer n, which may be negative, determine whether it's odd. Dividing by 2 and checking the remainder works, but there's a more direct route: parity lives entirely in a number's lowest bit. ANDing n with 1 reads that bit straight from its binary representation — no division involved, and the trick holds for negative numbers just as cleanly as positive ones.

Example 1:

Input: n = 4

Output: false

Example 2:

Input: n = 7

Output: true

Example 3:

Input: n = -3

Output: true

+ 8 hidden test cases run on Submit.

Constraints:

  • -2³¹ ≤ n ≤ 2³¹ − 1

n =

4