2274. Keep Multiplying Found Values by Two
My accepted C++ solution to LeetCode problem 2274, Keep Multiplying Found Values by Two, running in 0ms.
- Difficulty: Easy
- C++
- Runtime 0ms
- Memory 15.9MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
C++
Accepted on LeetCode — runtime 0ms, memory 15.9MB, accepted 2025-12-27.
class Solution {
public:
int findFinalValue(vector<int>& nums, int original) {
unordered_set<int> s(nums.begin(), nums.end());
while (s.count(original)) original *= 2;
return original;
}
};