LeetcodeBitwise AND of Numbers Range
Posted wuezs
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetcodeBitwise AND of Numbers Range相关的知识,希望对你有一定的参考价值。
题目链接:https://leetcode.com/problems/bitwise-and-of-numbers-range/
题目:
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.
思路:
32位整型,只需判断每一位在m~n之间是否有0存在,若有,该位 在AND操作中一定为0,只需判断32次
算法: