This commit is contained in:
kkunkka
2025-07-08 17:27:57 +08:00
parent 9996e2871e
commit ddc6ad5d0c

View File

@@ -0,0 +1,19 @@
package com.dota.bit._3133;
class Solution {
public long minEnd(int n, int x) {
long res = x;
long y = n - 1;
long a = 0;
while (y != 0) {
//找x第一个0
while ((x & (1 << a)) != 0) {
a++;
}
res |= (y & 1) << a;
y >>= 1;
a++;
}
return res;
}
}