Solution to Bitwise AND of Numbers Range by LeetCode

23 Aug


Question Name: Bitwise AND of Numbers Range

A variant of number of 1 bits in an interger. For any non-zero interger 0b?????????1000 (? could be 1 or 0, and there are zero or one or more 0s after the last 1 bit.), to remove the last 1 bit with bit AND operation, the least to-AND integer, or in other words the next effective integer larger than itself, is 0b????????(?+1)0000. And for any integer i between 0b?????????1000 and 0b????????(?+1)0000, such as 0b?????????1001, 0b?????????1000 & i = 0b?????????1000, no effect at all.


Leave a Reply

Your email address will not be published. Required fields are marked *