while n>0 and n>m:
n -= (n&-n)
can you please explain?, I kind of understand what you are doing here with the two's complement but how it's decreasing in size with n&-n is just purely amazing..
n-(n&-n) just remove the rightest "1" in bits. It is inspired by Binary Index Tree.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.