You are given an integer array nums and an integer original. While original appears in nums, replace original with 2 * original. When original is no longer in nums, stop and return its final value.
You are given an integer array nums and an integer original. While original appears in nums, replace original with 2 * original. When original is no longer in nums, stop and return its final value.
Example 1:
Input: {"nums":[5,3,6,1,12],"original":3}
Output: 24
Constraints:
1≤nums.length≤1000
1≤nums[i],original≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[5,3,6,1,12],"original":3}
original starts at 3. Each lookup in nums would be a full scan, so put nums into a hash set first.