Hi in the video you did not explain why we do n+= (n&-n) and I see it works but I don’t know why please help.
Why We do n+=(n&-n)
n &-n returns the rightmost 1 bit in n. So in order to get the rightmost bit we use this. You should watch the prerequisites video again , and you will know why we use this hack.
Just watch the prerequisites video of BIT once again.
I know why we do get the rightmost bit and my problem is not with it its with the proof of how bit work