There is a broken calculator that has the integer startValue on its display initially. In one operation, you can:
Given two integers startValue and target, return the minimum number of operations needed to display target on the calculator.
Examples
Example 1
Input: startValue = 2, target = 3
Output: 2
Explanation: Use double operation and then decrement operation {2 -> 4 -> 3}.
Example 2
Input: startValue = 5, target = 8
Output: 2
Explanation: Use decrement and then double {5 -> 4 -> 8}.
There is a broken calculator that has the integer startValue on its display initially. In one operation, you can:
Given two integers startValue and target, return the minimum number of operations needed to display target on the calculator.
Examples
Example 1
Input: startValue = 2, target = 3
Output: 2
Explanation: Use double operation and then decrement operation {2 -> 4 -> 3}.
Example 2
Input: startValue = 5, target = 8
Output: 2
Explanation: Use decrement and then double {5 -> 4 -> 8}.