LeetCode 717, Easy. Topics: Array. View on LeetCode.
Generate this problem as a practice environment: tested reference solution, 20 parametrized pytest cases, and a playground notebook:
Problem
We have two special characters:
- The first character can be represented by one bit
0.
- The second character can be represented by two bits (
10 or 11).
Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.
Examples
Constraints
- 1 <= bits.length <= 1000
- bits[i] is either 0 or 1.
Solution
Reference implementation from solution.py on GitHub, full suite in test_solution.py:
Complexity
Last modified on September 7, 2026