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; + } +};