leetcode.717.1比特与2比特字符

解题思路

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
class Solution {
public:
    bool isOneBitCharacter(vector<int>& bits) {
        int ed = bits.size()-1;
        int i=0;
        while(i<ed) {
            if(bits[i]) i+=2;
            else i++;
        }
        return i == ed;
    }
};