0991. Broken Calculator
https://leetcode.com/problems/broken-calculator
Description
There is a broken calculator that has the integer startValue
on its display initially. In on operation you can:
multiply the number on the display by
2
, orsubtract
1
from the number on the display.
Given two integers startValue
and target
, return the minimum number of operations needed to display target
on the calculator.
Example 1:
Example 2:
Example 3:
Example 4:
Constraints:
1 <= x, y <= 109
ac
Last updated