leetcode:Bitwise AND of Numbers Range
来源:互联网 发布:高频注入源码 编辑:程序博客网 时间:2024/06/05 03:20
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.
class Solution {public: int rangeBitwiseAnd(int m, int n) { int p = 0; while (m != n) { m = m>>1; n = n>>1; p++; } return m<<p; }};
0 0
- Python 垃圾回收机制
- Implicit intents with startService are not safe错误的解决方式
- 策略模式的应用——游戏中武器的选择
- 记录Ubuntu下搭建Android开发环境
- I帧、P帧和B帧的特点
- leetcode:Bitwise AND of Numbers Range
- 额,好吧,关于codeblocks的可能你没碰到的问题及解决办法
- xib中多个cell下的Autoresizing问题
- Python学习笔记之dict、set
- Valid Parentheses
- 第十七天:poj1019(纯属数学题目,找到规律就能解出)
- 快速幂或矩阵快速幂
- Android自定义View 自定义xml属性设置
- 计算机图形学