Skip to content

Commit 6b75ef3

Browse files
authored
Create 2154. Keep Multiplying Found Values by Two (#937)
2 parents 6c02567 + e5f2beb commit 6b75ef3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public:
3+
int findFinalValue(vector<int>& nums, int original) {
4+
bitset<1001> memo;
5+
6+
for (int x : nums)
7+
if (x <= 1000) memo[x] = 1;
8+
9+
int x = original;
10+
while (x <= 1000) {
11+
if (memo[x]) x *= 2;
12+
else break;
13+
}
14+
15+
return x;
16+
}
17+
};

0 commit comments

Comments
 (0)