【Leetcode_easy】717. 1-bit and 2-bit Characters
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;
完
【Leetcode_easy】717. 1-bit and 2-bit Characters的更多相关文章
- 【Leetcode_easy】1021. Remove Outermost Parentheses
problem 1021. Remove Outermost Parentheses 参考 1. Leetcode_easy_1021. Remove Outermost Parentheses; 完
- 【Leetcode_easy】1022. Sum of Root To Leaf Binary Numbers
problem 1022. Sum of Root To Leaf Binary Numbers 参考 1. Leetcode_easy_1022. Sum of Root To Leaf Binar ...
- 【Leetcode_easy】1025. Divisor Game
problem 1025. Divisor Game 参考 1. Leetcode_easy_1025. Divisor Game; 完
- 【Leetcode_easy】1029. Two City Scheduling
problem 1029. Two City Scheduling 参考 1. Leetcode_easy_1029. Two City Scheduling; 完
- 【Leetcode_easy】1030. Matrix Cells in Distance Order
problem 1030. Matrix Cells in Distance Order 参考 1. Leetcode_easy_1030. Matrix Cells in Distance Orde ...
- 【Leetcode_easy】1033. Moving Stones Until Consecutive
problem 1033. Moving Stones Until Consecutive 参考 1. Leetcode_easy_1033. Moving Stones Until Consecut ...
- 【Leetcode_easy】1037. Valid Boomerang
problem 1037. Valid Boomerang 参考 1. Leetcode_easy_1037. Valid Boomerang; 完
- 【Leetcode_easy】1042. Flower Planting With No Adjacent
problem 1042. Flower Planting With No Adjacent 参考 1. Leetcode_easy_1042. Flower Planting With No Adj ...
- 【Leetcode_easy】1046. Last Stone Weight
problem 1046. Last Stone Weight 参考 1. Leetcode_easy_1046. Last Stone Weight; 完
随机推荐
- 修改git提交的用户名和密码
目的:每个项目自定义Git提交的用户名和邮箱 1.在本地找到某个项目所在的地址 2.找到config文件 3.增加如下配置 4. ok,这样每个项目都可以定义提交者姓名和邮箱了
- 洛谷P1991 无线通讯网【最小生成树】
题目:https://www.luogu.org/problemnew/show/P1991 题意:有p个点的坐标,可以有s个点使得这s个点之间可以无限制通信. 要使所有点之间两两有通信的路径(可以是 ...
- spring中少用的注解@primary解析
这次看下spring中少见的注解@primary注解,例子 @Component public class MetalSinger implements Singer{ @Override publi ...
- mongodb存储引擎WiredTiger
MongoDB3.2后默认采用WiredTiger存储引擎. 组成 WiredTiger由三部分组成: Mongos: 负责查询请求的路由和对ShardServer的管理: ConfigServe ...
- margin与padding的区别
当子元素使用padding-top,不会影响到父元素的高度 使用margin-top,则会影响
- exam9.6&&7
emmm 改题稍紧张,以后几篇并一起写 9.6 (前十并没有参加本次考试) 于是我就rank8了 一道题一道题来 先说T1: 显然是一个高精度GCD,于是打算用计算器算一下时间复杂度 众所周知gcd是 ...
- Xmind8安装
现在新版安装极其简单.是deb安装包Xmind8安装小书匠 kindle 参照官网安装方法,在此记录下来,方便自己查找. 流程: 55ccaad0655d256ac5fb9fea8aa8569d.pn ...
- P2822 组合数问题——巧用前缀和
P2822 组合数问题 求的是C(i,j)有多少个是k的倍数: 首先,求组合数是有技巧的, 用杨辉三角求组合数,爽的一批: 但是,这样只能得90分,两个点T了: 因为k是不变的,我们可以用前缀和的思想 ...
- Qt学习大全
这边文章的目的是把自己之前写的关于Qt的文章整理归纳成一个Qt学习的专栏,会提供之前文章的导航,同时也会留一些坑待自己日后填. 1.Qt 元对象系统 2.Qt的信号和槽 3.Qt的插件开发 4.Qml ...
- 使用python3安装frida-tools出错
执行安装命令 pip3.6 install frida-tools 得到错误信息 error: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] c ...