201. Bitwise AND of Numbers Range

public class Solution {
    public int rangeBitwiseAnd(int m, int n) {
        int r=Integer.MAX_VALUE;
        while((m&r)!=(n&r))  r=r<<1;
        return n&r;
    }
}

  

posted @ 2017-10-31 13:08  Weiyu Wang  阅读(103)  评论(0编辑  收藏  举报