static int wing=[]()
{
std::ios::sync_with_stdio(false);
cin.tie(NULL);
return ;
}(); class Solution
{
public:
bool hasAlternatingBits(int n)
{
n^=n>>;
return (n&(n+))==;
}
};

这里用到了判定一个二进制n,位上全部为1的方法

(n&(n+1))==0

693. Binary Number with Alternating Bits的更多相关文章

  1. 【Leetcode_easy】693. Binary Number with Alternating Bits

    problem 693. Binary Number with Alternating Bits solution1: class Solution { public: bool hasAlterna ...

  2. 693. Binary Number with Alternating Bits - LeetCode

    Question 693. Binary Number with Alternating Bits Solution 思路:输入一个整数,它的二进制01交替出现,遍历其二进制字符串,下一个与上一个不等 ...

  3. [LeetCode&Python] Problem 693. Binary Number with Alternating Bits

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will a ...

  4. 【LeetCode】693. Binary Number with Alternating Bits 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 遍历判断 判断是否是交替模式 位运算 日期 题目地址 ...

  5. LeetCode 693 Binary Number with Alternating Bits 解题报告

    题目要求 Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits w ...

  6. [LeetCode] Binary Number with Alternating Bits 有交替位的二进制数

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will a ...

  7. [Swift]LeetCode693. 交替位二进制数 | Binary Number with Alternating Bits

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will a ...

  8. 987. Binary Number with Alternating Bits

    Description Given a positive integer, check whether it has alternating bits: namely, if two adjacent ...

  9. [LeetCode] 693. Binary Number with Alternating Bits_Easy

    Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will a ...

随机推荐

  1. fullCalendar插件基本使用

    效果图 html代码,需要引入jquery,layui,fullCalendar <!DOCTYPE html> <html lang="en"> < ...

  2. Angular之模版引用变量

    A template reference variable is often a reference to a DOM element within a template. It can also b ...

  3. HDU 6315 Naive Operations(线段树区间整除区间)

    Problem DescriptionIn a galaxy far, far away, there are two integer sequence a and b of length n.b i ...

  4. PTA 7-7 六度空间(广搜)

    “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论.这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够 ...

  5. 【centos】centos命令总结(持续更新)

    1.查看系统版本命令 转自:https://blog.csdn.net/networken/article/details/79771212 .查看内核版本 [root@localhost ~]# u ...

  6. selenium验证码和错误截图

    验证码的识别: 1,破解验证码 OCR识别(一般使用tesseract-ocr) 人工智能(AI机器学习 TensorFlow,成本大) 2,绕过验证码 1, 让开发人员临时关闭验证码 2,提供万能验 ...

  7. swift - label 的font 设置 文字字体和大小

    设置字体和颜色 lab.textColor = UIColor.init(hexColor: "795928") lab.font = UIFont.systemFont(ofSi ...

  8. shell加密工具shc的安装和使用

    1) 工具说明 shell脚本是可读写的, 很有可能会泄露敏感信息, 如用户名/密码/路径/IP等. 同样在shell脚本运行时会也泄露敏感信息. shc是一个加密shell脚本的工具, 它的作用是把 ...

  9. golang 简单的实现内 网 穿 透,用户访问本地服务。

    一.功能描述: 客户端通过访问外网服务器上指定端口,间接访问自已本地的内网服务. 二.原理图如下: 三.实现代码如下: server.go代码: package main; import ( &quo ...

  10. mysql联表更新使用join

    update TableA  as a inner join TableB as b on a.order_id=b.order_id set a.last_time='2018-01-01' whe ...