problem0201

package
v0.0.0-...-db5e768 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 0 Imported by: 0

README

201. 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.

Credits:Special thanks to @amrsaqr for adding this problem and creating all test cases.

解题思路

在草稿纸上,演算以下两组参数,就可以明白程序的用意了。 1.

m = 5, n = 7
5 : 0101
6 : 0110
7 : 0111
结果
4 : 0100
m = 6, n = 8
6 : 0110
7 : 0111
8 : 1000
结果
0 : 0000

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL