```
class Solution {
public:
bool isOneBitCharacter(vector<int>& bits) {
int n = bits.size();
if (n == 0) return false;
vector<bool> valid(n);
for (int i = 0; i < n; i++) {
valid[i] = !bits[i] && (i == 0 || valid[i - 1]) || i > 0 && bits[i - 1] && (i == 1 || valid[i - 2]);
}
return valid[n - 1] && (n == 1 || valid[n - 2]);
}
};
```