Simple easy-to-understand 2-line java solution using recursion


  • 0
    S
    public class Solution {
        public int rangeBitwiseAnd(int m, int n) {
            if (n == m) return n;
            return rangeBitwiseAnd(m / 2, n / 2) << 1;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.