文章作者:Tyan
博客:noahsnail.com | CSDN | 简书
1. Description
1-bit and 2-bit Characters2. Solution
class Solution {
public:
bool isOneBitCharacter(vector<int>& bits) {
int step = 1;
int index = 0;
while(index < bits.size()) {
step = bits[index]==1?2:1;
index += step;
}
return step == 1;
}
};
网友评论