Easy to understand C++ solution with modified for loop


  • 2
    E
    class Solution {
    public:
        bool isOneBitCharacter(vector<int>& b) {
            bool c;
            for (int i = 0; i < b.size();) {
                if (b[i]) c = 0, i+=2;
                else c = 1, ++i;
            }
            return c;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.