Skip to content

Commit e48746c

Browse files
authored
Create keep-multiplying-found-values-by-two.py
1 parent 5ca4ed1 commit e48746c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Time: O(n)
2+
# Space: O(n)
3+
4+
# hash table
5+
class Solution(object):
6+
def findFinalValue(self, nums, original):
7+
"""
8+
:type nums: List[int]
9+
:type original: int
10+
:rtype: int
11+
"""
12+
lookup = set(nums)
13+
while original in lookup:
14+
original *= 2
15+
return original

0 commit comments

Comments
 (0)