201. Bitwise AND of Numbers Range Medium

@problem@discussion
#Bit Manipulation



1/**
2 * [201] Bitwise AND of Numbers Range
3 *
4 * Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.
5 *  
6 * Example 1:
7 * 
8 * Input: left = 5, right = 7
9 * Output: 4
10 * 
11 * Example 2:
12 * 
13 * Input: left = 0, right = 0
14 * Output: 0
15 * 
16 * Example 3:
17 * 
18 * Input: left = 1, right = 2147483647
19 * Output: 0
20 * 
21 *  
22 * Constraints:
23 * 
24 * 	0 <= left <= right <= 2^31 - 1
25 * 
26 */
27pub struct Solution {}
28
29// problem: https://leetcode.com/problems/bitwise-and-of-numbers-range/
30// discuss: https://leetcode.com/problems/bitwise-and-of-numbers-range/discuss/?currentPage=1&orderBy=most_votes&query=
31
32// submission codes start here
33
34impl Solution {
35    pub fn range_bitwise_and(left: i32, right: i32) -> i32 {
36        0
37    }
38}
39
40// submission codes end
41
42#[cfg(test)]
43mod tests {
44    use super::*;
45
46    #[test]
47    fn test_201() {
48    }
49}
50


Back
© 2025 bowen.ge All Rights Reserved.