dsa1 min read
Bitwise AND of Numbers Range — Common Prefix
AND of all numbers in [left, right]. Result is the common prefix of left and right: keep shifting right until equal, then shift back.
Read →
webcoderspeed.com
2 articles
AND of all numbers in [left, right]. Result is the common prefix of left and right: keep shifting right until equal, then shift back.
Generate n-bit Gray code sequence where adjacent codes differ by exactly 1 bit. Formula: gray(i) = i ^ (i >> 1).