Ctrl K

End of the Doubling Chain

Easy
You are given an array values and a number start. While the current number appears in values, double it. As soon as the next number is missing from the array, stop. Return the number the process stopped at.
Example 1
values=[7, 14, 2, 28, 9], start=7 → 56

7 is there → 14, 14 is there → 28, 28 is there → 56, and 56 is not. The answer is 56.

Example 2
values=[4, 8, 16], start=2 → 2

2 is not in the array, so nothing is doubled and the answer is 2.

Constraints
  • 1 ≤ len(values) ≤ 1000
  • 1 ≤ values[i] ≤ 10⁴
  • 1 ≤ start ≤ 10⁴
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsClearing the Stacks Evenly EasyBusiest Meeting Room HardCross Out the Smallest First MediumPallets After the Moves MediumShelf Total After Orders Medium
loading Python…
Input
values=[7, 14, 2, 28, 9], start=7
Expected
56

Run checks the first 3 tests in your browser. Submit checks all 104 tests on the server, hidden ones included.