← ALL NOTES
Bit Manipulation

868. Binary Gap

Find the largest distance between two adjacent set bits in n's binary representation (0 if there are fewer than two 1s). Walk the bits low to high, remember the position of the previous 1, and update…

Loading…