# The Even Checkpoint

> Is this number in the even club? Prove it the fast way.

Canonical URL: <https://datadriven.io/problems/the_even_checkpoint>

Domain: Python · Difficulty: easy · Seniority: L3

## Problem

Given an integer n (possibly negative), return True if n is even, else False. Do NOT use %; use a bitwise operation.

## Worked solution and explanation

### Why this problem exists in real interviews

This tests **bitwise operation fundamentals**. It probes whether a candidate understands that the least significant bit determines parity, which is essential knowledge for low-level data processing and hashing.

> **Trick to Solving**
>
> Use bitwise AND with 1: `n & 1`. If the result is 0, the number is even. This works because the least significant bit is 0 for even numbers and 1 for odd numbers.

---

### Break down the requirements

#### Step 1: Apply bitwise AND with 1

The expression `n & 1` isolates the least significant bit.

#### Step 2: Return True if the result is 0

A result of 0 means the number is even; 1 means odd.

---

### The solution

**Bitwise parity check**

```python
def is_even(n: int) -> bool:
    result = (n & 1) == 0
    return result
```

> **Time and Space Complexity**
>
> **Time:** O(1). A single bitwise operation.
> 
> **Space:** O(1). No extra storage.

> **Interviewers Watch For**
>
> Whether you explain why this works at the bit level. Simply knowing the trick is not enough; you should articulate that even numbers have a 0 in the ones place in binary.

> **Common Pitfall**
>
> Negative numbers work correctly with `&` in Python because Python uses arbitrary-precision integers. In other languages, be aware of two's complement representation.

---

## Common follow-up questions

- How does this differ from using modulo? _(Tests performance awareness: bitwise AND is a single CPU instruction vs division for modulo.)_
- How would you check if a number is a power of 2? _(Tests `n & (n - 1) == 0` pattern.)_
- What other bitwise tricks are useful in data engineering? _(Tests knowledge of bit masking, XOR for deduplication, and hash function internals.)_

## Related

- [All practice problems](https://datadriven.io/problems)
- [Mock interview mode](https://datadriven.io/interview/the_even_checkpoint)
- [Python Interview Questions](https://datadriven.io/python-interview-questions)
- [Data Engineering Interview Prep Guide](https://datadriven.io/data-engineer-interview-prep)
- [Daily Challenge](https://datadriven.io/daily)

---

Source: DataDriven (https://datadriven.io). 100% free data engineering interview prep. Live code execution against Postgres 16, Python 3.11, and Spark sandboxes. No paywall, no premium tier, no signup gate.