From db77f73d228b15e7a32f96bee69ff1335972f220 Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Sat, 9 Nov 2024 23:58:14 +0530 Subject: [PATCH] Create 3133. Minimum Array End --- 3133. Minimum Array End | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 3133. Minimum Array End 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; + } +};