static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
bool isOneBitCharacter(vector<int>& bits)
{
int sz=bits.size();
int i=;
while(i<sz-)
{
if(bits[i]==)
i+=;
else
i+=;
}
return i==sz-;
}
};

这个题,从前向后扫,只要当前位为1,则不用管下一位是啥,必然要构成2位,所以当前位为1时,直接跳至下下个位置。

只有当末尾0前面有个落单的1时,末尾才不能为单,此时扫描到那个1的时候,加上2,i变为了sz

当末尾0前面不为非规则数字,i 必然不会跳过最后的0,会指向那个0,即i==sz-1

717. 1-bit and 2-bit Characters的更多相关文章

  1. LeetCode 717. 1比特与2比特字符(1-bit and 2-bit Characters)

    717. 1比特与2比特字符 LeetCode717. 1-bit and 2-bit Characters 题目描述 有两种特殊字符.第一种字符可以用一比特0来表示.第二种字符可以用两比特(10 或 ...

  2. 【Leetcode_easy】717. 1-bit and 2-bit Characters

    problem 717. 1-bit and 2-bit Characters 题意:solution1: class Solution { public: bool isOneBitCharacte ...

  3. leetcode 717. 1-bit and 2-bit Characters -easy

    https://leetcode.com/problems/1-bit-and-2-bit-characters/description/ We have two special characters ...

  4. [LeetCode&Python] Problem 717. 1-bit and 2-bit Characters

    We have two special characters. The first character can be represented by one bit 0. The second char ...

  5. LeetCode 717. 1-bit and 2-bit Characters

    We have two special characters. The first character can be represented by one bit 0. The second char ...

  6. 717. 1-bit and 2-bit Characters最后一位数是否为0

    [抄题]: We have two special characters. The first character can be represented by one bit 0. The secon ...

  7. 717. 1-bit and 2-bit Characters@python

    We have two special characters. The first character can be represented by one bit 0. The second char ...

  8. 【LeetCode】717. 1-bit and 2-bit Characters 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 遍历 日期 题目地址:https://leetcod ...

  9. 【LEETCODE】52、数组分类,简单级别,题目:717,661,746,628,643,849

    package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * ...

随机推荐

  1. 学习Junit资料

    以下是找到的一些有用的学习资料,先收藏了 http://www.blogjava.net/jiangshachina/archive/2011/12/14/366289.html http://www ...

  2. Android模拟器故障:waiting for target deviceto come online

    关闭再打开模拟器.删除再新建模拟器均无效. 解决办法:在AVD Manager中,选择立即冷启动(Cold Boot Now)模拟器.

  3. java图片操作--生成与原图对称的图片

    java图片操作--生成与原图对称的图片 package com.pay.common.util; import java.awt.image.BufferedImage; import java.i ...

  4. 实现Hibernate框架的CRUD

    1.创建Web项目HS_test如图所示: 2.创建数据库DBHSTest,在数据库中创建表Teacher,并插入数据 3.在Myeclipse中调出DB Brower视图 右键->New: 连 ...

  5. [BX]指令

    mov ax,[bx] 功能:bx中存放的数据作为一个偏移地址EA,段地址SA默认在ds中,将SA:EA处的数据送入ax中.即(ax)=((ds)*16+(bx)). mov [bx],ax 功能:b ...

  6. props传递数据

    一.传递数据 1.props 传入单数据 就像 data 一样,prop 可以用在模板内,同样也可以在 vm 实例中像“this.message”这样使用 <template> <d ...

  7. EF 更新实体 The instance of entity type 'BabyEvent' cannot be tracked because another instance

    加上AsNoTracking. 人不能两次踏入同一条河. 我 就踏入了.o(╥﹏╥)o

  8. IIS 7.5 上传文件大小限制

    上传插件:uploadify IIS版本:7.5 描述: 从IIS6升级到IIS7.5以后,网站上传文件大小被限制了,在Chrome下提示:ERR_CONNECTION_RESET,网上的各种方法都试 ...

  9. 迭代器、生成器 day13

    一 迭代器 迭代器的由来pythone2.2引进的,是一种序列(也是一种数据类型),也是为类对象提供一个序列的入口. for 循环str list tuple dict set 文件句柄可迭代: s ...

  10. iis日志分析软件及大文本切割软件下载

    在网上找了好几个日志分析软件,觉得这个是最简单.实用的,至少对我来说. 但这个软件有个缺点,就是日志比较大时,分析详细的会溢出,需要用到文本切割工具. 软件下载: iis日志分析软件 大文本切割软件 ...