problem

717. 1-bit and 2-bit Characters

题意:
solution1:

class Solution {
public:
bool isOneBitCharacter(vector<int>& bits) {
int i=;
while(i<bits.size()-)
{
if(bits[i]==) i+=;
else i+=;
}
return i==bits.size()-;
}
};

solution2:根据数组的特性计算。

class Solution {
public:
bool isOneBitCharacter(vector<int>& bits) {
int i=, n = bits.size();
while(i<n-)
{
//if(bits[i]==0) i+=1;
//else i+=2;
i += bits[i]+;
}
return i==n-;
}
};

参考

1. Leetcode_easy_717. 1-bit and 2-bit Characters;

2. Grandyang;

最新文章

  1. 跨界玩AR,迪奥、Hugo Boss等知名奢侈品牌将制造AR眼镜
  2. linux 下查看某个端口是否被占用
  3. fastjson格式化bean的简易属性过滤器
  4. [转]SIP穿越NAT&amp;FireWall解决方案
  5. Android为ViewPager增加切换动画——使用属性动画.
  6. MS Sqlserver 备份数据库SQL
  7. GoldenGate单向复制配置示例
  8. apicloud+融云实现即时通讯
  9. linux下启动和关闭网卡命令及DHCP上网
  10. 一个简单的模板引(han)擎(shu)
  11. 转 [分享一个SQL] 查会话阻塞关系,层次关系.
  12. APUE学习心得
  13. OWIN的概念初接触
  14. mysql 5.7 Warning: Using a password on the command line interface can be insecure. 解决方案
  15. C#创建、读写、增加、删除XML操作
  16. Android UI(五)云通讯录项目之联系人列表,带侧滑选择,带搜索框
  17. GCC卡常
  18. git使用简明教程
  19. Can't use Subversion command line client***Probably the path to Subversion executable is wrong. Fix
  20. SQL语句--查询任务

热门文章

  1. python多线程实现ping多个ip
  2. 用vue开发一个所谓的数独
  3. Selenium常用API的使用java语言之16-下拉框选择
  4. pid 及参数调试方法
  5. python - scrapy 爬虫框架 ( redis去重 )
  6. js图片上传 的方法
  7. Vagrant Docker Composer Yarn 国外资源下载慢或失败的问题
  8. Educational Codeforces Round 74
  9. python常用函数1
  10. python-ros No module named PyKDL