diff --git a/3133. Minimum Array End b/3133. Minimum Array End new file mode 100644 index 0000000..39150bb --- /dev/null +++ b/3133. Minimum Array End @@ -0,0 +1,19 @@ +class Solution { +public: + long long minEnd(int n, int x) { + long long res = x; + long long i_x = 1; + long long i_n = 1; + + while (i_n <= n - 0) { + if ((i_x & x) == 0) { + res |= i_x * (i_n & (n - 1) ? 1 : 0); + + i_n <<= 1; + } + i_x <<= 1; + } + + return res; + } +};