Skip to content
LC-2154 Easy LeetCode

2154. Keep Multiplying Found Values by Two

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 71% Topics: Array, Hash Table, Sorting, Simulation
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(n)

# hash table
class Solution(object):
    def findFinalValue(self, nums, original):
        """
        :type nums: List[int]
        :type original: int
        :rtype: int
        """
        lookup = set(nums)
        while original in lookup:
            original *= 2
        return original

Solution from kamyu104/LeetCode-Solutions · MIT