717. 1-bit and 2-bit Characters

(1)代码:

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

 

posted @ 2017-12-11 22:38  西瓜刀刀刀  阅读(80)  评论(0编辑  收藏  举报