201. Bitwise AND of Numbers Range
来源:互联网 发布:中考倒计时软件下载 编辑:程序博客网 时间:2024/05/29 17:26
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
For example, given the range [5, 7], you should return 4.
Credits:
Special thanks to @amrsaqr for adding this problem and creating all test cases.
public class Solution { public int rangeBitwiseAnd(int m, int n) { int moveFactor = 1; while (m != n) { m >>= 1; n >>= 1; moveFactor <<= 1; } return m * moveFactor; }}
阅读全文
0 0
- 安卓应用启动时黑屏和白屏的原因及解决办法
- Java 内存分配全面浅析(转载)
- JAVA生成验证码
- poj3904 Sky Code —— 唯一分解定理 + 容斥原理 + 组合
- Android中的广播Broadcast
- 201. Bitwise AND of Numbers Range
- Codeforces Round #416 (Div. 2) B. Vladik and Complicated Book
- bzoj 1007 [HNOI2008]水平可见直线
- windos 安装pip
- Microsoft.Jet.OLEDB.4.0和Microsoft.ACE.OLEDB.12.0的区别
- 死锁:补充
- c# 通过查看注册表的方式来判断电脑安装office的版本
- linux shell 编程中 read i y=${i%%,*} echo "$y" 输出是变量i的值。 问下。后面的%%,*有什么用?
- React Native0.42以下报错编译