From e5f2bebd974aefb6f5db3debd186c1e4b16d7c4d Mon Sep 17 00:00:00 2001 From: chayan das Date: Wed, 19 Nov 2025 23:33:57 +0530 Subject: [PATCH] Create 2154. Keep Multiplying Found Values by Two --- 2154. Keep Multiplying Found Values by Two | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2154. Keep Multiplying Found Values by Two diff --git a/2154. Keep Multiplying Found Values by Two b/2154. Keep Multiplying Found Values by Two new file mode 100644 index 0000000..5d286f3 --- /dev/null +++ b/2154. Keep Multiplying Found Values by Two @@ -0,0 +1,17 @@ +class Solution { +public: + int findFinalValue(vector& nums, int original) { + bitset<1001> memo; + + for (int x : nums) + if (x <= 1000) memo[x] = 1; + + int x = original; + while (x <= 1000) { + if (memo[x]) x *= 2; + else break; + } + + return x; + } +};