while (n > m) n ^= (n & -n);
If u don't wanna lose the input value.
int res = n;
while (res > m)
res ^= (res & -res);
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.