leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
3133.cpp (285B)
0 class Solution {
1 public:
2 long long minEnd(int n, long long x) const {
3 using ull = unsigned long long;
5 for (ull i = 1, j = n - 1; j > 0 && i > 0;) {
6 if (!(x & i)) x |= j & 1 ? i : 0, j >>= 1;
7 i <<= 1;
8 }
10 return x;
11 }
12 };