490. Broken Calculator
MediumGreedy
The calculator can only double the display or subtract 1. Print the minimum operations to turn start into target.
Input format
One line: start target
Output format
The minimum operations.
Example 1
Input
2 3
Output
2
Example 2
Input
5 8
Output
2
Constraints
1 ≤ start, target ≤ 10⁹
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…