We are given two integers:
target: The score we need to reach.maxDoubles: The maximum number of times we can press the Double button.Initially, the score is 1.
We have two possible operations:
Increment: Increase the current score by 1.
x \rightarrow x+1
Double: Multiply the current score by .
x \rightarrow 2x
The Double button can only be used at most maxDoubles times.
Our task: Find the minimum number of moves required to reach exactly target.
Important observations:
For example:
target = 19
maxDoubles = 2
One optimal sequence is: